Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. how do I fix this

how do I fix this

Scheduled Pinned Locked Moved Managed C++/CLI
helpc++question
5 Posts 5 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    girl7432
    wrote on last edited by
    #1

    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
    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"<>students;
    cout<<"enter "<>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 "<

    J L P U 4 Replies Last reply
    0
    • G girl7432

      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
      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"<>students;
      cout<<"enter "<>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 "<

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      You have to use arrays. So you should learn about them: Arrays - C++ Tutorials[^] std::array - cppreference.com[^] The example output shows also that you need two loops: One to read the user input and store it within the array and another one to print the items. It is up to you what to store in the array: The mark or the grade. Depending on that the conversion has to be done in the first or second loop. But I would store the mark because that is the data entered by the user and is therefore not lost and can be re-used (e.g. when the next task is extending your program). Because this is homework, you will not get a final solution here. But you should be able to proceed with my above tips.

      1 Reply Last reply
      0
      • G girl7432

        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
        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"<>students;
        cout<<"enter "<>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 "<

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        if(mark>=90)
        grade[0];

        The expression in the second line does nothing.

        cout<<"student "<
        The value of x in the above statement is the loop counter, so it has no relation to the actual grade value you are trying to deal with.

        This is fairly basic C/C++ that you need to study and understand.

        1 Reply Last reply
        0
        • G girl7432

          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
          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"<>students;
          cout<<"enter "<>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 "<

          P Offline
          P Offline
          Patrice T
          wrote on last edited by
          #4

          Quote:

          I don't know what to do anymore. Help me

          Use the debugger to check what part of your code match your expectations and which part don't, it will help you to marrow the search of defects. When you don't understand what your code is doing or why it does what it does, the answer is debugger. Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool. Debugger - Wikipedia, the free encyclopedia[^] Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^] The debugger is here to show you what your code is doing and your task is to compare with what it should do. There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug. Here is links to references books on C and C++ by the authors of the languages. Note than C is the ancestor of C++, so knowing C is always useful with C++. The C Programming Language - Wikipedia, the free encyclopedia[^] https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^] http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^] C++ Programing Language[

          1 Reply Last reply
          0
          • G girl7432

            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
            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"<>students;
            cout<<"enter "<>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 "<

            U Offline
            U Offline
            User 13080335
            wrote on last edited by
            #5

            my english is poor ,so I want to help you ,but I can't tell you in english. we can learn together.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups