Loops
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 0, k = 0, q;
for (k = 0; k < 10; k++)
{
p++;
if (k == 9)
break;
}
printf("%d",p);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
10
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 0, k = 0, q = 1;
for (k = 0; k < 10; k++)
{
p++;
q++;
continue;
}
printf("%d, %d", p, q);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
10, 11
- Which keyword can be used for coming out of recursion?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
return
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int k = 0;
while (k = 0)
printf("Veg...\n");
printf("Non-Veg...\n");
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Non-Veg...
- How many times while loop condition is tested in the following C code snippets, if k is initialized to 0 in both the cases?
while (k < m)
k++;
————-
do
k++;
while (k <= m);
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
m+1, m+1