C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - Point Out Correct Statements (Q.No. 6)
6.
Which of the following statements are correct about the below C-program?
#include<stdio.h>
int main()
{
int x = 10, y = 100%90, i;
for(i=1; i<10; i++)
if(x != y);
printf("x = %d y = %d\n", x, y);
return 0;
}
1 : | The printf() function is called 10 times. |
2 : | The program will produce the output x = 10 y = 10 |
3 : | The ; after the if(x!=y) will NOT produce an error. |
4 : | The program will not produce output. |
Discussion:
70 comments Page 4 of 7.
Vini said:
1 decade ago
I have a doubt. Because the if inside the for loop is not satisfying. So how could it be. ?
Mayya said:
1 decade ago
FOR loop has got no body..... so IF gets executed after the FOR loop... followed by printf
Ashish soni said:
10 years ago
Program successfully compile and execute.
It produce output: x = 10; y = 10 for 9 times.
It produce output: x = 10; y = 10 for 9 times.
(1)
Srinath said:
1 decade ago
I don't now after if condition put semicolon in C you clearly explain thank you kavya.
Sramona said:
1 decade ago
X=10, y=10, then how if (x != y) statement will execute ? please some one answer ASAP.
Pall said:
1 decade ago
X=10, y=10 , then how if(x != y) statement will execute ?pls some 1 answer asap
Sujan said:
1 decade ago
But the condition says that i<10 rite? So how can we get x and y as 10?
Angelica said:
1 decade ago
Will it run even if the for loop has no opening and closing curly brace?
AVI said:
10 years ago
I don't now after if condition put semicolon in C you clearly explain.
Kans said:
1 decade ago
@Gopi
It means only the ramainder alone will be taken into account.
It means only the ramainder alone will be taken into account.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers