i have been trying to make create this program, it's kinda hard for me to get help in real life because I'm the only computer science student in my second semester.
this is c++. I have to use arrays
I have to make a program that shows grades, based on marks. The number of students depends on the user input.
grade A >=90
grade B >=80
grade C >=70
grade D >=60
grade F <=59
based on the homework my lecturer has given me, the output has to be like this
Enter the number of students: 4
Enter 4 marks: 40 55 70 58
student 0 mark is 40 and grade is C
student 1 mark is 55 and grade is B
student 2 mark is 70 and grade is A
student 3 mark is 58 and grade is B
This is my code:
#include<iostream>
using namespace std;
int main(){
int students;
int mark;
int x;
char grade[6]={'A','B','C','D','F','\0'};
cout<<"enter the number of students"<<endl;
cin>>students;
cout<<"enter "<<students<<" marks "<<endl;
for(x=0;x<students;x++){
cin>>mark;
if(mark>=90)
grade[0];
else if(mark>=80)
grade[1];
else if(mark>=70)
grade[2];
else if(mark>=60)
grade[3];
else
grade[4];
cout<<"student "<<students<<" mark is "<<mark<<" and grade is "<<grade[x];
}
}
I don't know what to do anymore. Help me