0% found this document useful (0 votes)
2K views4 pages

Quiz 2

The document contains 10 multiple choice questions related to C programming concepts like data types, operators, control flow, enums, and switch statements. The questions test understanding of syntax, semantics, and output of small code snippets. Overall the questions cover basic but important aspects of C like variable declaration, conditional logic, enums, and switch-case statements.

Uploaded by

Viraj Bhosale
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)
2K views4 pages

Quiz 2

The document contains 10 multiple choice questions related to C programming concepts like data types, operators, control flow, enums, and switch statements. The questions test understanding of syntax, semantics, and output of small code snippets. Overall the questions cover basic but important aspects of C like variable declaration, conditional logic, enums, and switch-case statements.

Uploaded by

Viraj Bhosale
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.

Does follwing code compile successfully


#include<stdio.h>
enum hello
{sunbeam,pune,karad; };
main()
{
enum hello a;
printf(�%d�,a);
}

1. No error
2. Error in the statement: {sunbeam,pune,karad; };
3. Error in the statement: enum hello a;
4. Error in the statement: printf(�%d�,a);

Answers:2

2. What is output of following program.


#include <stdio.h>

int main(void)
{
if((-1 && 1)&&( !printf("0")))
printf("%s","TRUE");
else
printf("%s","FALSE");

return 0;
}
Answers
1. TRUE
2. 0FALSE
3. FALSE
4. 0TRUE

Answers:2

3. What will be the output of following program ?


#include<stdio.h>

int main()
{
int i = 50;
if(~i>>7)
{
printf("Sunbeam,Pune");
}
else
{
printf("Sunbeam, Karad");
}

return 0;
}
Answers
1. Sunbeam,Pune
2. Sunbeam, Karad
3. Compile Time Error
4. No Output
Answer:1

4. What will be the output of following program ?

#include <stdio.h>
void main()
{
int a=10;
switch(a){
case 5+5:
printf(�Pune\n�);
default:
printf(�Karad\n�);
}
}
Answers
1. Pune
Karad
2. Pune
3. Karad
4. Compile time error.

answer:1

5. What will be the output of following program ?

#include<stdio.h>
enum menu
{ a=2,b,c,d=-1,e};
enum menu m;
int main()
{
printf(�%d %d�,b+a,e+d);
}
Answers
1. 2 3
2. 0 1
3. 5 -1
4. Error

answer:3

6. #include <stdio.h>

int main()
{
int var;

var=5>7?6:1!=8<9?50:60;

printf("%d", var);

return 0;
}
Answers
1. 6
2. 50
3. 1
4. 60

answer:4

7. #include<stdio.h>
int main()
{
int x = 100;
char y = 270;
if(x == y)
printf("x is equal to y\n");

else if(x > y)


printf("x is greater than y\n");

else if(x < y)


printf("x is less than y\n");
return 0;
}
Answers
1. complie time error
2. x is equal to y
3. x is less than y
4. x is greater than y

Answer:4

8. What will be the output of following program ?


#include<stdio.h>

int main()
{
char ch = 65;
switch(++ch)
{
case 'A':
printf("Hinjewadi\n");
break;
case 'B':
printf("MarketYard\n");
default:
printf("Karad\n");
break;
}
return 0;
}
Answers
1. MarketYard
Karad
2. Karad
3. Hinjewadi
4. Compile Time Error

Answer:1

9. In switch case the case values can be :


Answers
1. Integer
2. Float
3. Character
4. Both 1 & 3

answer:4

10. #include<stdio.h>
enum E_COURSE
{
EDAC,EDBDA,EDMC;
};
main()
{
enum E_COURSE x;
printf("%d",x);
}
Answers
1. No error
2. Error in the statement: EDAC,EDBDA,EDMC;
3. Error in the statement: enum E_COURSE x;
4. Error in the statement: printf(�%d�,x);

Answer:2

You might also like