Answer to Question #2760 in C++ for Bahaa

Question #2760
Write a program that reads the marks of a student in the exams (mid-term,final,attendance) and print if succeeded or not.
1
Expert's answer
2011-06-21T07:53:53-0400
#include <iostream.h> //some times this file has title iostream,
without extension. If compilation error write #include <iostream>

#define MAX_MARK 10 //max mark
//if you will have problems write: using namespace std;

void main()
{
int i, n;
int m;
double am;
cout<<"Enter number of exams: "; cin>>n;
am=0;
for(i=0; i<n; i++)
{
& do
& {
& cout<<"Mark number "<<i+1<<": "; cin>>m;
& if(m<0 || m>MAX_MARK) cout<<"Invalid value\n";
& }
& while(m<0 || m>MAX_MARK);
& am+=m;
}
am/=(double)n;
if(am>=MAX_MARK*0.7) cout<<"Student is successful\n";
else cout<<"Student is not successful\n";
cin>>i;//delay until user not to enter some value
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS