Using FUNCTIONS,combine all four given programs into a single program.
Each part should have its own function (basically you’re converting FOUR programs into FOUR functions). The different functions should be accessible through a menu that resembles the following:
1) Array Review
2) If-Else Review
3) Loop Review 1
4) Loop Review 2
Choose a number:
If you enter the number 1, for example, it should read 5 numbers from numbers.txt and calculate the average (part 1 of the in-class assignment).
Here is what I have so far :
#include<iostream>
#include<fstream>
using namespace std;
//Function prototypes
float getAverage ();
int getScore ();
int getSum ();
int getFactorial();
int main() {
int arrayReview,IfelseReview, loopReview1, loopReview2 ;
My program has no errors. Can anybody gave me some input on what's missing in my program , in order to get the correct outputs. Thanks!
for example : If you enter the number 1, for example, it should read 5 numbers from numbers.txt and calculate the average (part 1 of the in-class assignment).
How can your program be error free if its not returning the correct results. You mean it compiles right? Do you know the files are opening correctly?
What average do/should you get when you enter 1? Do any of the 4 functions return a correct result?
Just a suggestion:
Why not use switch(case) and put your functions in each case block just as a temporary simplification