Write program in C that does Take student name Take his home
Solution
Please find the required program along with its output. Please see the comments against each line to understand the step.
// Example program
 #include <iostream>
 #include <string>
using namespace std;
int main()
 {
 string name;
 double hw1, hw2, hw3, hw4, q1, q2, q3, q4, m1, m2, f, avghw, avgq, fs; //initialize variables
 cout << \"Enter student name: \" <<endl;
 cin >> name; //read name
   
 cout << \"Enter homework 1 score: \" << endl; //read homework grades
 cin >> hw1;
 cout << \"Enter homework 2 score: \" << endl;
 cin >> hw2;
 cout << \"Enter homework 3 score: \" << endl;
 cin >> hw3;
 cout << \"Enter homework 4 score: \" << endl;
 cin >> hw4;
cout << \"Enter quiz 1 score: \" << endl; //read quiz grades
 cin >> q1;
 cout << \"Enter quiz 2 score: \" << endl;
 cin >> q2;
 cout << \"Enter quiz 3 score: \" << endl;
 cin >> q3;
 cout << \"Enter quiz 4 score: \" << endl;
 cin >> q4;
   
 cout << \"Enter midterm 1 score: \" << endl; //read midterm grades
 cin >> q1;
 cout << \"Enter midterm 2 score: \" << endl;
 cin >> q2;
   
 cout << \"Enter final exam score: \" << endl; //read final exam grade
 cin >> f;
 avghw = (hw1 + hw2 + hw3 + hw4)/4; //calculate homework average
   
 avgq = (q1 + q2 + q3 + q4)/4; //calculate quiz average
   
 fs = (avghw * 0.10) + (avgq * 0.10) + (m1 * 0.20) + (m2 * 0.20) + (f * 0.40); //calculate final grade
   
 cout << \"Student : \" << name << endl; //print name
 cout << \"Final grade : \" << fs << endl; //print final grade
   
 if(fs >= 60) //if final grade >= 60, then print pass
 cout << \"Pass\" << endl;
 else //else print failed
 cout << \"failed\" << endl;
  
 }
-------------------------------------------------------------
OUTPUT:


