CS110 Assignment 2 (Theory) Total mark 8 Instructions: 1. Write your name and ID on top of your solution. 2. Use Word or
Posted: Tue May 24, 2022 7:57 am
question: Choose and explain in your own words the idea of only one program of the following, then produce a flowchart. Use correct symbols (this is a suggested website to draw flowcharts: https://app.diagrams.net/).
#include <iostream> using namespace std; int main() { } const int NUMGRADES =4; const int NUMSTUDENTS =20; int i, j; double grade, total, average; for (i = 1; i <= NUMSTUDENTS; i++) { total = 0; for (j=1; j <= NUMGRADES; j++) cout << "Enter a grade for this student"; cin >> grade; total= total + grade; } average = total/NUMGRADES; " << i cout <<"\n The average for student << " is " << average << "\n\n"; } return 0;
#include <iostream> #include <iomanip> using namespace std; int findMax (int, int); int main() { int firstnum, secnum, max; cout << "\nEnter a number: "; cin >> firstnum; cout << "Enter a second number: "; cin >>secnum; max = findMax (firstnum, secnum); cout << "\nThe maximum of the two numbers is " << max << endl; return 0; } int findMax (int x, int y) { int maximum; if (x >= y) maximum = x; else maximum =y; return maximum;
CS110 Assignment 2 (Theory) Total mark 8 Instructions: 1. Write your name and ID on top of your solution. 2. Use Word or any other application to save your solution as a PDF. Submit your file as a PDF. 3. Do not copy the solution from a friend or the internet. If you copy, you will get a zero mark on this assignment. 4. Submit your solution before the duedate (18.10.1443). Assignment #include <iostream> using namespace std; int main() { } const int NUMGRADES =4; const int NUMSTUDENTS =20; int i, j; double grade, total, average; for (i = 1; i <= NUMSTUDENTS; i++) { total = 0; for (j=1; j <= NUMGRADES; j++) cout << "Enter a grade for this student"; cin >> grade; total= total + grade; } average = total/NUMGRADES; " << i cout <<"\n The average for student << " is " << average << "\n\n"; } return 0;
#include <iostream> #include <iomanip> using namespace std; int findMax (int, int); int main() { int firstnum, secnum, max; cout << "\nEnter a number: "; cin >> firstnum; cout << "Enter a second number: "; cin >>secnum; max = findMax (firstnum, secnum); cout << "\nThe maximum of the two numbers is " << max << endl; return 0; } int findMax (int x, int y) { int maximum; if (x >= y) maximum = x; else maximum =y; return maximum;