C Programming Quiz : Data Types and Storage Classes

C Quiz : Data Types and Storage Classes

C Programming Quiz : Data Types and Storage Classes

C Programming Quiz - Data Types and Storage Classes

1. Identify wrong C Keywords below?
  • A) case, enum, register, typedef
  • B) break, else, long, switch
  • C) char, extern, intern, return
  • D) auto, double, int, struct

Answer is C)
Description:
char, extern, return are all keywords but, 'intern' is not a keyword. Remaining are all valid keywords.

2. Signed and unsigned representation is available for?
  • A) float, double, long double
  • B) short, int, long, char
  • C) Both A & B
  • D) None of the above

Answer is A)
Description:
Real numbers like float, double and long double do not support unsigned representation.

3. Range of signed char and unsigned char are?
  • A) 0 to +127 -128 to -1
  • B) -128 to -1 0 to +127
  • C) 0 to 255 -128 to +127
  • D) -128 to +127 0 to 255

Answer is D)
Description:
Advantage of an unsigned representation is only to increase the upper limit i.e positive limit. Size of a char remains same i.e 1 Byte.

4. Left most bit 0 in Singed representation indicates?
  • A) An Unsigned number
  • B) A Positive number
  • C) A Negative Number
  • D) None of the above

Answer is B)
Description:
For positive numbers 0 is used as a left most bit.
For negative numbers 1 is used as a left most bit.

5. If you do not specify a storage class for a Variable?
  • A) Output is null always.
  • B) You get a compiler warning.
  • C) You get compiler error.
  • D) None of the above.

Answer is D)
Description:
Yes. Even if you do not specify a Storage class for a Variable, AUTOMATIC storage class is applied.

6. What is a C Storage Class?
  • A) C Storage Class decides what is the Scope and Life of a variable.
  • B) C Storage Class decides what is the default value of a variable.
  • C) C Storage decides where to or which memory store the variable.
  • D) All the above.

Answer is D)
Description:
Read all the three options.

7. Every C Variable must have?
  • A) Type
  • B) Storage Class
  • C) Both Type and Storage Class
  • D) Either Type or Storage Class

Answer is C)
Description:
Yes. A C Variable should have both Type and Storage Class.
Eg. int a=5; By default its Storage Class is auto. auto int b=10;

8. What is the default C Storage Class for a variable?
  • A) static
  • B) extern
  • C) register
  • D) auto

Answer is D)
Description:
int a=5; // auto is by default
auto int b=10; // storage class

9. Choose a right statement

    A) Variables of type auto are initialized fresh for each block or function call.

    B) Variables of type static are initialized only first time the block or function is called.

    C) Variables of type register are initialized each time the block or function is executed.

    D) All the above.

Answer is D)
Description:
Read the all three options.

10. What is the output of the program?
  • A) 15 10
  • B) 10 15
  • C) 10 10
  • D) Compiler error

Answer is A)
Description:
Automatic or Register variables have block scope and life. Most recent definition takes precedence. {...} is a block.


Submit your Quiz Question
Submit your quiz question to us, We will feature your quiz question in our blog with your credits.