Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

help me . c++. Arrays

c++ array

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 girl2383

girl2383

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 06 February 2017 - 09:43 PM

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






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download