Quiz-2 of c programming language

Quiz-2 of c programming language

 

Q 1 – What is the output of the following program?

#include<stdio.h>

main()

{

char s[] = “Fine”;

*s = ‘N’;

printf(“%s”, s);

}

A – Fine

B – Nine

C – Compile error

D – Runtime error

Q 2 – What is the output of the following program?

#include<stdio.h>

main()

{

int i = 1;

while( i++<=5 )

printf(“%d “,i++);

}

A – 1 3 5

B – 2 4

C – 2 4 6

D – 2

Q 3 – int x=~1; What is the value of ‘x’?

A – 1

B – -1

C – 2

D – -2

Q 4 – Identify the C compiler of UNIX.

A – gcc

B – cc

C – Borland

D – vc++

Q 5 – The library function strrchr() finds the first occurrence of a substring in another string.

A – Yes

B – Strstr()

C – strchr()

D – strnset()

Q 6 – In the given below code, if a short int value is 5 byte long, then how many times the while loop will get executed?

#include<stdio.h> int main (){   int j = 1;   w-hile(j <= 300)   {      printf(“%c %d\n”, j, j);      j++;   }   return 0;}

A – Unlimited times

B – 0 times

C – 300 times

D – 5 times

Q 7 – C is the successor of ___ programming language.

A – C++

B – B++

C – B

D – Mini C

Q 8 – Turbo C in 16 bit DOS OS, the correct range of “long double” is,

A – 3.4E-4932 to 3.4E+4932

B – 3.4E-4932 to 1.1E+4932

C – 4.1E-4932 to 5.1E+4932

D – 0.7E-4932 to 1.8E+4932

Q 9 – What is the value of ‘y’ for the following code snippet?

#include<stdio.h> main(){   int x = 1;      float y = x>>2;      printf( “%f”, y );}

A – 4

B – 0.5

C – 0

D – 1

Q 10 – What is the outpout of the following program?

#include<stdio.h> main() {      enum { india, is=7, GREAT };       printf(“%d %d”, india, GREAT);}

A – 0 1.

B – 0 2

C – 0 8

D – Compile error

 

Answer with exaplaination:

1)B

Explaination

*s=’N’, changes the character at base address to ‘N’.

2)CExplaination

Explaination

2 4 6, at while first compared and later incremented and in printf printed first and incremented later.

3)D

Explaination

-2, the one’s compliment of 1 is 1110 (binary) which is equivalent to two’s compliment of 2, ie -2

4)B

Explaination

‘cc’ full form is C Compiler and is the compiler for UNIX. gcc is GNU C compiler for linux. Borland and vc++ (Microsoft visual c++) for windows.

5)B

Explaination

Strstr() finds the first occurrence of a substring in another string.

6)C

Explaination

If while(j <= 300),then whatever the size short int value, the while loop condition will execute until j value becomes 300.

#include<stdio.h> int main (){   int j = 1;      while(j <= 300)   {      printf(“%c %d\n”, j, j);      j++;   }   return 0;}

7)C

Explaination

B is a programming language developed at Bell Labs in 1969. It is derived from BCPL (Basic Combined Programming Language). It is designed by Ken Thompson with Dennis Ritchie.

8)B

Explaination

Explanation: The integral and precession value varies depending upon the number of bytes designated for a particular data type.

9)C

Explaination

0, data bits are lost for the above shift operation hence the value is 0.

10)C

Explaination

0 8, enums gives the sequence starting with 0. If assigned with a value the sequence continues from the assigned value.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *