C Looping MCQ
Q1. The C code ‘for(;;)’ represents an infinite loop. It can be terminated by ___________
- break
- exit(0)
- terminate
- abort()
Answer:- (A).
Explanations :None.
Explanations :None.
- for (i = 0; i < n; i++)
for (j = 0; j < n; j += 5) - for (i = 0, j = 0; i < n, j < n; i++, j += 5)
- for (i = 0; i < n;i++){}
for (j = 0; j < n;j += 5){} - none of the mentioned
Answer:- (B).
Explanations :None.
Explanations :None.
- for (i = n; i>0; i–)
- for (i = n; i >= 0; i–)
- for (i = n-1; i>0; i–)
- (i = n-1; i>-1; i–)
Answer:- (D).
Explanations :None.
Explanations :None.
- variable
- function
- typedef
- macros
Answer:- (D).
Explanations :None.
Explanations :None.
#includeint main() { short i; for (i = 1; i >= 0; i++) printf("%d\n", i); }
- The control won’t fall into the for loop
- Numbers will be displayed until the signed limit of short and throw a runtime error.
- Numbers will be displayed until the signed limit of short and program will successfully terminate
- This program will get into an infinite loop and keep printing numbers with no errors
Answer:- (C).
Explanations :None
Explanations :None
#includevoid main() { int k = 0; for (k) printf("Hello"); }
- Compile time error
- hello
- Nothing
- Varies
Answer:- (A).
Explanations :None
Explanations :None
#includevoid main() { int k = 0; for (k < 3; k++) printf("Hello"); }
- Compile time error
- Hello is printed thrice
- Nothing
- Varies
Answer:- (A).
Explanations :None
Explanations :None
#includevoid main() { double k = 0; for (k = 0.0; k < 3.0; k++) printf("Hello"); }
- Run time error
- Hello is printed thrice
- Hello is printed twice
- Hello is printed infinitely
Answer:- (B).
Explanations :None
Explanations :None
#includevoid main() { double k = 0; for (k = 0.0; k < 3.0; k++); printf("%lf", k); }
- 2.000000
- 4.000000
- 3.000000
- Run time error
Answer:- (C).
Explanations :None
Explanations :None
#includevoid main() { int k; for (k = -3; k < -5; k++) printf("Hello"); }
- Hello
- Infinite hello
- Run time error
- Nothing
Answer:- (D).
Explanations :None
Explanations :None
Copyright © 2022 Shineskill Software Pvt. Ltd., All rights reserved.