Tuesday, January 25, 2022

Average Student Grades Using For Loop and Arrays in C++

 A simple program to ask the user to give five grades of the students and then the program will compute the average grade of the student using a C++ programming language.

 I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg





Program Listing

grades.cpp

#include <iostream> #include <numeric> #include <array> constexpr int NumGrades = 5; int main() { std::array<int, NumGrades> grades; std::cout <<"\n\n"; std::cout << "\tAverage Student Grades Using For Loop and Arrays in C++"; std::cout <<"\n\n"; for (int i = 0; i < NumGrades; ++i) { std::cout << "\tEnter Student Grade No. " << i+1 << " : "; std::cin >> grades[i]; } auto sum_grades = std::accumulate(grades.cbegin(), grades.cend(), 0); auto avg_grade = sum_grades / NumGrades; std::cout <<"\n\n"; std::cout << "\tThe Average Student Grades : " << avg_grade; std::cout <<"\n\n"; std::cout << "\tEnd of Program"; std::cout <<"\n\n"; }


No comments:

Post a Comment