Write a program in the C ++ language that executes the following application
1- Type function to find grade (a, b, c, d, e, fnil)
2-. Write a program that requires the user to enter student marks
3- Use the function to show the student's mark with grade
I WROTE THE CODE ALONG WITH THE COMMENTS:
CODE:
#include <iostream>
using namespace std;
char grade(int);
int main()
{
//variables declaration.
int i,n;
char value;
cout<<"Enter number of students: ";
cin>>n;
int student_marks[n];
cout<<"Enter student marks: ";
for(i=0;i<n;i++) //for loop used to scan the
student_marks.
{
cin>>student_marks[i];
}
cout<<endl;
for(i=0;i<n;i++)
{
value=grade(student_marks[i]); //calling the grade function to find
the grade based on marks.
cout<<"Grade of student "<<(i+1)<<":
"<<value<<endl;
}
return 0;
}
char grade(int marks)
{
//Based on marks different grades will be given.
if(marks>=80)
{
return 'A';
}
else if(marks<80 && marks>=79)
{
return 'B';
}
else if(marks<79 && marks>=69)
{
return 'C';
}
else if(marks<69 && marks>=59)
{
return 'D';
}
else if(marks<59 &&marks>=49)
{
return 'E';
}
else
{
return 'F';
}
}
OUTPUT:
SCREENSHOT OF THE CODE:
EXPLANATION:
I TOOK N STUDENT MARKS AND USING THE FUNCTION TO FIND THE GRADE.
Get Answers For Free
Most questions answered within 1 hours.