C mcq test 4

3
For more MCQ Question visit www.csemcq.com Q1. If an integer need 2 bytes of storage then the maximum value of an signed integer is: a) 2 16 -1 b) 2 15 -1 c) 2 16 d) 2 15 Ans b Explanation: In signed magnitude form one bit is used to store the sign so only 15 bits are available to store the value. Q2. If cse is an input then the following program fragment results in Char x,y,z; Printf(“%d”,scanf(“%c”, “%c”, “%c”,&x,&y,&z)); results in a) Syntax error b) A fatal error c) Segmentation violation d) Printing of 3 Ans d Explanation: Scanf() function returns number of successful matches I.e. 3 in this case Q3 The statement printf(“%d”,sizeof(“”)); prints a) An error message b) 0 c) garbage d) 1 Ans d Q4 The following program fragment: if (a=5) printf(“a is five”); else printf(“a is not five”); result in the printing of a) a is five b) a is not five c) nothing d) garbage ans a q5 main()

description

c,c++, programming,mcq,multiple choice question

Transcript of C mcq test 4

Page 1: C mcq test 4

For more MCQ Question visit www.csemcq.com

Q1. If an integer need 2 bytes of storage then the maximum value of an signed integer is:

a) 216-1

b) 215-1

c) 216

d) 215

Ans b

Explanation: In signed magnitude form one bit is used to store the sign so only 15 bits are

available to store the value.

Q2. If cse is an input then the following program fragment results in

Char x,y,z;

Printf(“%d”,scanf(“%c”, “%c”, “%c”,&x,&y,&z)); results in

a) Syntax error

b) A fatal error

c) Segmentation violation

d) Printing of 3

Ans d

Explanation: Scanf() function returns number of successful matches I.e. 3 in this case

Q3 The statement printf(“%d”,sizeof(“”)); prints

a) An error message b) 0 c) garbage d) 1

Ans d

Q4 The following program fragment:

if (a=5)

printf(“a is five”);

else

printf(“a is not five”);

result in the printing of

a) a is five

b) a is not five

c) nothing

d) garbage

ans a

q5 main()

Page 2: C mcq test 4

For more MCQ Question visit www.csemcq.com

{

Int i=5;

i=(++i)/(i++);

printf(“%d”,i);

}

prints:

a) 2 b) 5 c) 1 d) 6

Ans a

Q6 The statement printf(“%d”,10?0?5:11:12);

prints:

a) 10 b) 0 c) 12 d) 11

Ans d

Q7 if you are using “open” function for opening a file the file handle should be of--------type

a)FILE

b) int

c) char

d)none of the above

ans a;

Q8 What will be the output of following program:

#define ISLOWER(a)(a>=97&&a<=127)

#define TOUPPER(a)(a=a-32)

int main()

{

char ch=’c’;

if(ISLOWER(ch))

ch=TOUPPER(ch);

printf(“%c”,ch);

}

Ans a)C b)c c)99 d) None of the above

Q9.

Find the output of program:

int main()

{

int i;

Page 3: C mcq test 4

For more MCQ Question visit www.csemcq.com

for(i=-1;i<=10;i++)

{

if(i<5)

continue;

else

break;

printf("gets printed only once");

}

}

Ans a)No output b) Gets Printed only once c)Error d) None

Q10

Find the output of program:

int main()

{

if(printf("C for yourself how it works\n"))

getch();

}

a) Error b) C for yourself how it works c) none

e) C for yourself how it works

C for yourself how it works

C for yourself how it works

C for yourself how it works

----------------------------------

Ans b