(Solved):Find the mistake in the following code (explain):——————————————————————————–#include iostreamusing namespace std; View Answer…

 

Question

Find the mistake in the following code (explain):


#include <iostream>
using namespace std;
int main()
{
char STOP;
char name;
int nameTotal = 0;
int numberOfStudents = 0;
cout<<"==============================================="<<endl;
cout<<" NUMBER of REGISTERED STUDENTS "<<endl;
cout<<"==============================================="<<endl;
cout<<" "<<endl;
cout<<"Enter Students NAME or type STOP to QUIT: "<<endl;
cin>>name;
while(name!='STOP'){
nameTotal += name;
numberOfStudents++;
cout<<"Enter next Students NAME or type STOP to QUIT: "<<endl;
cin>>name;
}
cout<<"Total of Registered Students: "<<numberOfStudents<<endl;
cout<<"Average Students names: "<<nameTotal/numberOfStudents<<endl;
cout<<" "<<endl;
cout<<"============================================"<<endl;
return 0;
}

 

EXPERT ANSWER

Refer to the updated program and the comments given

Scroll to top