Chapter - 4: The Loop Control Structure

Which of the following statements are true for the following program? [Note: The program have a printing mistake that i is not defined, so it is assumed that i is defined in the program]


D
Sections
8
Exercises

A

B

C

D

E

1

2

3

4

5

6

7

8

9

#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) would NOT produce an error.

4. The program will not produce any output.

5. The printf() function is called infinite times.


Ans: Following statements are true for the above program.

2. The program will produce the output x = 10 y = 10.

3. The ; after the if (x != y) would NOT produce an error.


© 2020 Garbage Valuegarbage value logo