0
Average age
Why is that not true? To show avg age of array int ages[] = {19, 24, 36, 45, 56, 52, 21, 27, 24, 34, 29, 60, 40, 42, 45, 47, 22, 30, 34, 20, 18, 26, 51, 43, 47, 39, 22, 34, 56, 52, 21, 27, 24, 37, 19, 24, 36, 45, 44, 49, 23, 25, 19, 40, 29, 60, 40, 42, 45, 47, 61, 30, 19, 43, 47, 39, 41, 46, 29, 24, 21, 25, 28}; int size = 63; int *p = ages; int avg; for(int i=0;i<size;i++) { cout << *p << endl; avg += *p; p++; } cout<<avg/size;
2 Réponses
+ 6
selin remove the
cout << *p << endl;
And add the
<< endl; to your last
}
cout << avg / size << endl;
}
btw you should use something other than avg as a variable name as most languages see it as a keyword or function elsewhere.
+ 2
Thank you