Loops
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int k = 0;
for (fun(); k == 1; k = 2)
printf("Executed in loop\n");
printf("Executed After loop\n");
}
int fun()
{
return 1;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Executed After loop
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int *ptr = NULL;
for (fun(); ptr; ptr = 0)
printf("Executed in loop\n");
printf("Executed After loop\n");
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Compilation Error
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
for (int k = 0; k < 1; k++)
printf("Executed In for loop\n");
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Depends on the standard compiler implements
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
while ()
printf("Executed In while loop ");
printf("Executed After loop\n");
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Compilation Error
main.c: In function ‘main’:
main.c:4:16: error: expected expression before ‘)’ token
while ()
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
printf("Ajit ");
Label1: Label2:
printf("Sumi ");
printf("Abhay ");
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Ajit Sumi Abhay