0% found this document useful (0 votes)
161 views

C++ Quiz

1. The document contains instructions for a 25 question quiz with multiple choice answers to be completed in 15 minutes. 2. Questions test knowledge of C programming concepts like data types, operators, functions, arrays, pointers, and strings. 3. Answers are to be selected from the multiple choice options provided for each question.

Uploaded by

Vishal Madan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views

C++ Quiz

1. The document contains instructions for a 25 question quiz with multiple choice answers to be completed in 15 minutes. 2. Questions test knowledge of C programming concepts like data types, operators, functions, arrays, pointers, and strings. 3. Answers are to be selected from the multiple choice options provided for each question.

Uploaded by

Vishal Madan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Bits n - bytes

TEAM NUMBER:
PARTICIPANT 1: PARTICIPANT 2:

Instructions
1. The quiz contains 25 questions which have to be solved in 15

minutes. 2. The correct answer will fetch three marks. 3. One mark will be deducted for a wrong answer. No negative marking for questions unattempted.
Q1.) #define val 100 void main() { printf(%d,val); #define val 1000 printf(%d,val*10);}

What is the output of the given code? a) Compiler Error b) 100 1000 c) 100 10000 None Q2.) Find the value returned by fun(n), for all n belongs to positive integers int fun(int n) { int i=0; while((i*i)<n) i++; return i; }

d)

a) ceil(sqrt(n))
Q3.)

b)

floor(sqrt(n))

c)

ceil(sqrt(n))+1 d) floor(sqrt(n))+1

Array passed as an argument to a function is interpreted as a) Address of the array b) Address of the 1st element of the array c) Values of the 1st element of the array d) Number of element of the array

Q4.)

fputs function is used to i. write characters to a file ii. takes 2 parameters iii. returns a character iv. requires a file pointer c) all are false d) only i,ii and iv are true

a) all are true b) only i and ii are true

Q5.)

int fun(int *c) { *c+=5; return(4); } void main() { int x=3; x=x+fun(&x); } What is the value of x?

a) 12
Q6.)

b)

c)

d)

None

unsigned int foo(unsigned int n,unsigned int r) { if(n>0) return ((n%r)+foo(n/r ,r)); else return 0; } What will be the value returned by foo(445,20)? a) 5 b) 7 c)

d)

None

*Q7.)

int z, x=5, y= - 10, a=4, b=2; z = x++ - --y * b/a; What number will z in the sample code above contain? a) 5 b) 11 c) 10 d) 12

Q8.)

According to the Standard C specification, what are the respective minimum sizes (in bytes) of the following three data types: short; int; and long? a) 1, 2, 2 b) 1, 2, 4 c) 2, 2, 4 d) 2, 4, 8

Q9.)

Which one of the following variable names is NOT valid? a) go_cart b) go4it c) 4season _what

d)

*Q10.) int f(int *a,int n) { if(n<=0) return 0; else if(*a%2==0) return *a+f(a+1,n-1); else return *a-f(a+1,n-1); } int main() { int a[]={12,7,13,4,11,6}; Printf(%d,f(a,6)); return 0; } What is the output of the given code? a) -9 b) 5 Q11.) #define int char main(){ int i=97; printf(%d,sizeof(i)); } What is the output of the given code? a) 1 b) 2 Error *Q12.) main(){ show(); } void show() { printf(FERVOUR 2012); } What is the output of the given code? a) FERVOUR 2012 b) Compiler Error:Function Definition of show not found c) Compiler Error:Type mismatch in re-declaration of show d) Linker error:Module_show not found

c)

15

d)

19

c)

Compiler error d)

Runtime

Q13.)

main() { Char p[]=me; int i; for(i=0;p[i];i++) printf(%c%c%c%c,p[i],*(p+i),*(i+p),i[p]); }

What is the output of the given code? a) mmmmeeee b) *Q14.) main() { int a=5,*j; void *k; j=k=&a; printf(\n%u%u,j++,k++); } What is the output of the given code? a) 5 garbage value b) An address will be outputted twice

mmmm

c)

mmmmeeem

d)

None

c) compiler error d)unexpected result

Q15.)Which one of the following will declare a pointer to an integer at address 0x200 in memory?

a) int *x;
*x = 0x200; b) int *x = &0x200; c) int *x = *0x200; d) int *x = 0x200; *Q16.) main() { int i,a; printf(%d,printf(PRINT%d\t,scanf(%d%d,&i,&a))); } What is the output of the given code? b) PRINT2 7 c) PRINT1 7 d)none

a) PRINT1 6
Q17.)

main() { cout<<FERVOUR 2012; main(); } c) FERVOUR 2012 FERVOUR 2012..Stack Overflow d) Undefined Result

What is the output of the given code? a) FERVOUR 2012 b) Compiler Error Q18.)

"My salary was increased by 15%!"

Select the statement which will EXACTLY reproduce the line of text above. a) b) c) d) e) Q19.) printf("\"My salary was increased by 15/%\!\"\n"); printf("My salary was increased by 15%!\n"); printf("My salary was increased by 15'%'!\n"); printf("\"My salary was increased by 15%%!\"\n"); printf("\"My salary was increased by 15'%'!\"\n"); main() { printf(%c,6[Fervour]); }

What is the output of the given code? a) 6 b) Fervour

c)

d)

Q20.)

main()

{ char p[]=%d\n; p[1]=c; printf(p,65); } What is the output of the given code? a) A b) Q21.)

65

c)

d)

#define <stdio.h> main() { printf(%d%d,sizeof(NULL),sizeof()); }

What is the output of the given code? a) 2 1 b)

2 2

c)

1 1

d)

4 0

Q22.)

Which of the following is the equivalent of ++*ptr ? b) None (*ptr)++ c) ++ptr d)

a) *ptr++
Q23.)

void main() { while(1) { if (printf(%d, printf(%d))) break; else continue; }}

What is the output of the given code? a) Compilation error None of these Q24.)

b)

Runtime error c)

Garbage Value d)

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); } }

a) 1 2 3 4 5 6 7 8 9 b) 1 2 3 10 c) 4 5 6 7 8 9 10 d) 4 5 6 7 8 9 Q25.) void main() { char str1[]=hello; char str2[]=hello; if(str1==str2) printf(equal); else printf(unequal); }

What is the output of the given code?

a) equal
these

b) unequal

c) Cant say

d) None of

You might also like