Thread: how to create a loop in grading system

  1. #1
    Registered User
    Join Date
    Jun 2016
    Posts
    6

    how to create a loop in grading system

    hi.. i need to put loop in my program base on the out put given. can anyone advice how create loop in my program. here is the output

    Enter no. of students: 3
    Enter no. of courses: 3


    >>Enter student ID: 123
    >>Enter marks for 123:
    Enter mark for course #1: 56
    Grade: D
    Enter mark for course #2: 45

    Grade: E
    Enter mark for course #3: 89

    Grade: A
    Total Marks = 190

    Average Mark = 63.33
    >>PROCEED TO THE NEXT SEMESTER...

    >>Enter student ID: █


    Here is my programme which i need to put loop.
    Code:
    #include <stdio.h>
      int main()
    {
        int marks, stud, cours, total, sum;
        
        printf( " Enter No Of Students :");
        scanf("%d", &stud);
        printf(" Enter No 0f Course :");
        scanf("%d", &cours);
        printf("Enter Mark :");
        scanf("%d", &marks);
        
        {
         
        if( marks >= 80 && marks <= 100)
                printf( " Grade A");
                
        else if(marks >= 70  )
                printf( " Grade B");
               
       else if( marks >= 60  )
                printf( " Grade C");
           
           else if( marks  >= 50  )
                printf( " Grade D");
            
        else if( marks >= 40  )
                printf( " Grade E");
                
        else if(  marks >= 0 && marks <= 39)
                printf( " Grade F");
         
        }
         return 0;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    A development process

    So in the first instance, you make
    Code:
    #include <stdio.h>
    void gradeStudent( ) {
        int marks, stud, cours, total, sum;
        
        printf( " Enter No Of Students :");
        scanf("%d", &stud);
        printf(" Enter No 0f Course :");
        scanf("%d", &cours);
        printf("Enter Mark :");
        scanf("%d", &marks);
        
        {
         
        if( marks >= 80 && marks <= 100)
                printf( " Grade A");
                
        else if(marks >= 70  )
                printf( " Grade B");
               
       else if( marks >= 60  )
                printf( " Grade C");
           
           else if( marks  >= 50  )
                printf( " Grade D");
            
        else if( marks >= 40  )
                printf( " Grade E");
                
        else if(  marks >= 0 && marks <= 39)
                printf( " Grade F");
         
        }
    }
    
    int main()
    {
        gradeStudent();
         return 0;
    }

    But then perhaps, the number of students is the loop variable, so move that part back to main
    Code:
    int main()
    {
        int stud;
        printf( " Enter No Of Students :");
        scanf("%d", &stud);
    
        gradeStudent();
        return 0;
    }
    From there, it's an easy step to
    for ( i = 0 ; i < stud

    Well, I'm sure you can take it from there.....
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Student Grading System
    By nadeera in forum C Programming
    Replies: 11
    Last Post: 12-10-2015, 11:38 PM
  2. Tried to create a basic RPG-Need help with Class/Subclass System
    By creativeethers in forum C++ Programming
    Replies: 6
    Last Post: 01-25-2012, 07:40 PM
  3. Create an AIM-like IM system?
    By muffinman8641 in forum C++ Programming
    Replies: 1
    Last Post: 03-11-2011, 12:49 PM
  4. Create an operating system
    By histevenk in forum Tech Board
    Replies: 20
    Last Post: 10-17-2007, 04:30 AM
  5. noobish file create system
    By C+noob in forum C++ Programming
    Replies: 4
    Last Post: 07-06-2005, 07:30 PM

Tags for this Thread