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.
Vivek kumar said:
7 years ago
Thanks @Kavya.
SONIYA VIJAY said:
1 decade ago
x = 10, y = 10.
For loop has no statement inside it.
After the if statement there is a; so no o/p will be produced but it will not give any error.
The printf statement will print the values of x and y.
So the answer is (B) 2, 3.
For loop has no statement inside it.
After the if statement there is a; so no o/p will be produced but it will not give any error.
The printf statement will print the values of x and y.
So the answer is (B) 2, 3.
Sandeep said:
1 decade ago
Please show me X and Y value correct answer.
Sandeep said:
1 decade ago
X=10, Y=10 for loop statement no inside.
Avijit said:
1 decade ago
When this statement execute y = 100% 90 the y value become 10, the loop continue 9 times and the value of if either true or false its no matter because there is a semicolon after that that means the if end there then it comes to the printf statement and print the x value as 10 and y value as 10; so option B is the correct answer.
AVI said:
10 years ago
I don't now after if condition put semicolon in C you clearly explain.
Mayya said:
1 decade ago
FOR loop has got no body..... so IF gets executed after the FOR loop... followed by printf
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.
Gopinath.nan said:
1 decade ago
What is the meaning of y=100%90 ?
Ravi said:
1 decade ago
Good explanation sai thanx a lot.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers