0

hi there

I want to give a for loop in my programm that if any student fails in more than four subject he will not be able to go to the next level. if average is less than 40 then the student will be failed . i tried in many ways. but compiler is not taking at all. below i am just showing the logs for the loop but not the whole program. the program has got other parts. Basically i could not put the exact logic.

#include <stdio.h>

main()
{
int s,t; 
Printf ("This student is not allowed to go to the next level as he fails in more than two subject\n");
scanf("%d",&s); /*here what will be the address of s ?*/
for (t=1, t>=4, t++)
}
2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Clockowl
0

*

for(t=1; t >= 4; t++){<code>}

You use comma's in the for() loop when you want multiple statements, like this:

int i, j, n;

for(i = j = 0, n = 5; i < 10 && j <= 20; printf("%d %d %d", i, j, n), i++, n = n * 2,  j += 2);

Nobody in his right mind would write the above code, but it shows that you use comma's to seperate statements, while you use semicolons to specify if they are initializing (gets executed before the loop, once), condition (checked after each iteration, break; if false), or erm.. well the last part. That just gets executed each loop, you *could* write all your code in there. :D

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.