0% found this document useful (0 votes)
335 views4 pages

Cquiz 3

The student failed their recent exam with only 6 out of 30 marks. They attempted 8 questions but only answered 2 correctly. The questions were related to C programming concepts like loops, conditional statements, switch cases, break and continue keywords.

Uploaded by

sim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
335 views4 pages

Cquiz 3

The student failed their recent exam with only 6 out of 30 marks. They attempted 8 questions but only answered 2 correctly. The questions were related to C programming concepts like loops, conditional statements, switch cases, break and continue keywords.

Uploaded by

sim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Find the output of the following code:


int main()
{
int n=1;
for(printf("Step 1 \t");printf("Step 2\t"),n--;printf("Step 4\t"))
{
printf("Step 3\t");
}
}
Answers
1. Step 1 Step 2 Step 3 Step 4 Step

Help
Simran Meena (69316)
Summary
Summary of your recent exam

Result: Fail
Marks: 6/30
Percentage: 0.00 %
Questions: 10
Correct Answers: 2
Attempted: 8
1. Find the output of the following code:
int main()
{
int n=1;
for(printf("Step 1 \t");printf("Step 2\t"),n--;printf("Step 4\t"))
{
printf("Step 3\t");
}
}
2. What will be the output of the following code?
#include<stdio.h>
int main() {
int i = -3, j = 0;
while (i <= 3, j < 10) {
if (i >= 0)
break;
else {
i++;
j++;
}
printf("%d, %d\n", i, j);
continue;
}
printf("\nSunbeam");
return 0;
}
Answers

2. -2, 1 -1, 2 0, 3 Sunbeam

3. what will be the output of following code?


#include <stdio.h>
int main(void) {
int a = 2;
do {
switch (a, a + 1) {
case 2:
printf("\nYou are in b ");
break;
case 3:
printf("\nYou are in c ");
break;
default:
printf("\nYou are in default");
}
} while (a--);
return 0;
}
Answers
1. You are in c You are in b You are in default

4. #include <stdio.h>
void main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
if (i==5)
goto print;
i++;
}
}
Answers
1. Hello world
2. Error (ans
3. 5 4 3 2 1
4. 0 1 2 3 4

5. Find the output of the following code:


int main()
{
int n=5;
while(n--)
{
if(!n)
continue;
}
printf("%d",n);
}
Answers
1. Infinite Loop
2. Will cause to Runtime Error
3. 5
4. -1 (ans

6. what will be the output of following code?


int main() {
int x;
for (x = 1; x <= 5; x++) {
switch (x) {
case 1:
printf("Sunbeam");
continue;
case 2:
case 3:
case 4:
break;
case 5:
printf("Info");
}
printf(".com");
}
}
Answers
1. SunbeamInfo.com
2. Sunbeam.com.com.comInfo.com (ans

7. void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
}
Answers
1. 1
2. Infinite loop
3. Garbage value (ans
4. 0

8. What is the output of the following code?


#include<stdio.h>
void main()
{
int s=0;
while(s++<10)
{
if(s<4 && s<9)
continue;
printf(“\n%d\t”,s);
}
}
Answers
1. 1 2 3 1 0
2. 4 5 6 7 8 9
3. 4 5 6 7 8 9 10 (ans
4. 1 2 3 4 5 6 7 8 9

9. #include <stdio.h>
int main()
{
int i = 0, j = 0;
while (i<5,j<10)
{
i++;
j++;
}
printf("%d %d", i, j);
}
Answers
1. 5 5
2. syntax error
3. 5 10
4. 10 10 (ans

10. 10. What will be the output?


#include<stdio.h>
int main()
{
int x=5;
switch( x*2,5)
{
case 15:
printf("One");
break;
case 10:
printf("Two");
break;
default:
printf("Three");
}
return 0;
}
Answers
1. One
2. Compilation Error
3. Three (ans
4. Two

You might also like