. The code below is to calculate the average age of 10 students, but contains some logical and syntax errors. Review the codes and rewrite a correct version to solve the problem given.
#includeusing namespace std/* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char** argv) {int age[10];double avg;for (int i=0;i<=10;i++);>=10;i++);>cin>> age[0];sum= age[i+1]+ age[i];} avg = sum /0;cout < "the="" average="" age="" is="" "=""><><>return 0; }
using namespace std
/* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char** argv) {
int age[10];
double avg;
for (int i=0;i<=10;i++);>=10;i++);>
cin>> age[0];
sum= age[i+1]+ age[i];
} avg = sum /0;
cout < "the="" average="" age="" is="" "=""><><>
return 0; }
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here