int main()
. This would make your code more readable :)return (u>x) ? u : x;
the function does not give me one value. it give me a list of values |
if
else
blocks to see which number is large and return it. Or you could do as CreativeMFS suggested, although I would go with the first method for clarity, unless you are happy with the conditional operator.
int max(int, int): Each time returns the biggest number among two integers which are sent as parameters. This function can be used to find the largest deviation from the average. |
|
|
The average monthly rainfall for the last 8 years (historical average) (2001 – 2009) is stored in the first column of a file called rain.dat In addition, last year’s monthly rainfall averages (current average) are stored in the second column of the same file. Write a C++ program that reads the data file and displays a graph showing the variation between the historical and current monthly averages month by month. In the graph (see sample below), months are represented by the first 3 letters abbreviation of the months’ name. Every ‘*’ represents 10 units. Moreover, the left part of the graph represents negative variations, while the right part represents positive variations with respect to the average. Your program should also display the largest deviation from the average. Your program must implement and use the following functions: 1. bool open_file(): To open and validate the existence of the input file. If the file fails to open for any reason then the function should return false and the program terminates. 2. void draw_Line(int, int): To plot a line (corresponding to a month) inside the chart based on the month’s readings 3. string num_to_month(int): To convert integers (1-12) to the 3 letters month abbreviations. 4. int max(int, int): Each time returns the biggest number among two integers which are sent as parameters. This function can be used to find the largest deviation from the average. |
|
|