Control Instructions(C Programming ) Questions and Answers

Question 1.

By default, the data type of a constant without a decimal point is int, whereas the one 

with a decimal point is a double.


  1.    Yes
  2.    No
Explanation:-
Answer: Option A. -> Yes

6 is int constant. 
6.68 is double. 
6.68L is long double constant. 
6.68f is float constant. 



Question 2.

We want to test whether a value lies in the range 2 to 4 or 5 to 7. Can we do this using a switch?


  1.    Yes
  2.    No
Explanation:-
Answer: Option A. -> Yes


We can do this in following switchstat ement


switch(a)
{
case 2:
case 3:
case 4:
/* some statements */
break;
case 5:
case 6:
case 7:
/* some statements */
break;
}



Question 3.

A char variable can store either an ASCII character or a Unicode character.


  1.    True
  2.    False
Explanation:-
Answer: Option A. -> True

Yes, we can store either an ASCII character or a Unicode character in a char variable.


Question 4.

The way the break is used to take control out of switch and continue to take control 

of the beginning of the switch?


  1.    Yes
  2.    No
Explanation:-
Answer: Option B. -> No

continue can work only with loops and not with switch



Question 5.

Can we use a switch statement to switch on strings?


  1.    Yes
  2.    No
Explanation:-
Answer: Option B. -> No

The cases in a switch must either have integer constants or constant expressions.



Question 6.

The modulus operator cannot be used with a long double.


  1.    True
  2.    False
Explanation:-
Answer: Option A. -> True

fmod(x,y) - Calculates x modulo y, the remainder of x/y. 
This function is the same as the modulus operator. But fmod() performs 

floating point or long doubledivisions.



Question 7.


Which of the following statements are correct about the below program?


#include<stdio.h>
int main()
{
int n = 0, y = 1;
y == 1 ? n=0 : n=1;
if(n)
printf("Yes\n");
else
printf("No\n");
return 0;
}
  1.    Error: Declaration terminated incorrectly
  2.    Error: Syntax error
  3.    Error: Lvalue required
  4.    None of above
Explanation:-
Answer: Option C. -> Error: Lvalue required

No answer description available for this question. 



Question 8.

If scanf() is used to store a value in a char variable then along with the value a carriage return

(r) also gets stored it.


  1.    True
  2.    False
Explanation:-
Answer: Option B. -> False

No, the carriage return tells the compiler to read the input from the buffer after 

ENTER key is pressed.



Question 9.

Which of the following sentences are correct about a switch loop in a C program?

1:switch is useful when we wish to check the value of variable against a particular set of values.

2:switch is useful when we wish to check whether a value falls in different ranges.

3:Compiler implements a jump table for cases used in switch.

4:It is not necessary to use a break in every switch statement.


  1.    1,2
  2.    1,3,4
  3.    2,4
  4.    2
Explanation:-
Answer: Option B. -> 1,3,4



Question 10.

A short integer is at least 16 bits wide and a long integer is at least 32 bits wide.


  1.    True
  2.    False
Explanation:-
Answer: Option A. -> True

The basic C compiler is 16 bit compiler, below are the size of it's data types 
The size of short int is 2 bytes wide(16 bits).
The size of long int is 4 bytes wide(32 bits).