C++ examples for Data Type:Array
Averages six test scores.
#include <iostream> using namespace std; #include <iomanip> void main()//from ww w. ja v a2 s . c o m { char s_name[] = "University"; float scores[6] = {8.7, 9.4, 6.0, 7.0, 10.0, 6.7}; float average=0.0; int ctr; for (ctr=0; ctr<6; ctr++) { average += scores[ctr]; } average /= float(6); cout << "At " << s_name << ", your class average is " << setprecision(2) << average << "\n"; return; }