0

Do the following for the user-entered number of students.
Find the average marks for a student of his marks in 3 subjects. Print whether he
passed or failed. A student will fail if his average is less than 50. Use for loop...can u help me writing this pgm.....thankss:-/

4
Contributors
4
Replies
6
Views
10 Years
Discussion Span
Last Post by Adak
0

To give you an example of how this problem could be solved:

Input number of students

Loop while a counter is less then students
{
    input grade1
    input grade2
    input grade3
    average = (grade1 + grade2 + grade3) / 3
    if average < 50
        print "you've failed!"
}

And here's an example of a for-loop:

for (int i =0;i<10;i++)
    printf("%d\n", i);

This will show the numbers 0-9.

So now you can start translating this to C. Come back with questions if you get stuck!

Niek

0

For what exactly is this for loop being used?What does it do?Does is take in the marks or does it restrict the number of students to 10?

0

The for loop restricts the number of students being assigned marks. It could restrict it to 0, or to 20000, (or more), depending on what the user input as his/her choice.

Edited by Adak: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.