Loops
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int k = 0;
do
{
k++;
if (k == 2)
continue;
printf("Interview");
} while (k < 2);
printf(" Mania");
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Interview Mania
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 5;
if (k == 5)
{
printf("Hello Interview Mania");
break;
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Compilation Error
main.c: In function ‘main’:
main.c:8:13: error: break statement not within loop or switch
break;
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 2;
if (k == 2)
{
printf("Hello Interview Mania");
continue;
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Compilation Error
main.c: In function ‘main’:
main.c:8:13: error: continue statement not within a loop
continue;
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 0;
for (k = 0; k < 6; k++)
if (k < 4)
{
printf("Interview Mania");
break;
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Interview Mania
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 0;
int L = 0;
for (k = 0; k < 4; k++)
{
for (L = 0; L < 3; L++)
{
if (k > 1)
continue;
printf("Interview Mania\n");
}
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
"Interview Mania" is printed 6 times