Objective type (MCQ) questions on C programming language Part 2

C programming language multiple type questions for exams point of view 

Basic C programming MCQ


1) Choose correct answer..
#include<stdio.h>
main()
{
/* Multi Line Comment
This line is ignored by compiler
*/
printf("Hello C.."); 
}
A) #include is a Preprocessor Directive
B) <stdio.h> is a header file with predefined functions like printf, scanf etc
C)
#include
main()
{

}
is a mandatory function to be included in every C Program.
D) All the above

2) Correct way of commenting a single line is.?
A) /*printf("Hello C.."); printf("How are you.");  
B) //printf("Hello C.."); printf("How are you.");
C) /*printf("Hello C.."); printf("How are you.");*/
D) /printf("Hello C..");/ printf("How are you.");

Explanation:
With Multi-Line comment or BLOCK Comment characters, respond to C's two lines of comments. /* ....*/
Only // is a Single Line Commenting characters.

3) Single Line Comment // is also called.?
A) C++ Style Comment.
B) Java Style Comment.
C) PHP Style Comment.
D) All the above.

4) What is an Identifier in C Language.?
A) Name of a Function or Variable
B) Name of a Macros
C) Name of Structure or Union
D) All the above.

Explanation:
int age=25;
//here age is an Identifier

5) An Identifier may contain.?
A) Letters a-z, A-Z in Basic character set. Unicode alphabet characters other languages.
B) Underscore _ symbol.
C) Numbers 0 to 9 Unicode Numbers in other languages.
D) All the above.

6) What is the number of characters used to distinguish Identifier or Names of Functions and Global variables.?
A) 31.
B) 32.
C) 33.
D) 28

Explanation:
First 31 characters in general. If first 31 characters are same for two different identifiers, compiler gets confused.
 
7) What is length of an Identifier that is unique for Non Global Variables and Non Function Names.?
A) 32.
B) 63.
C) 64.
D) 68.

Explanation:
  • if 31 is present choose. Because old compilers support up to 31 only.
  • Up to first 63 characters you can show differentiation in the name of say 
  • int abcdefghijklmnopqrstuvwxyz1234567788= 10;
  • int abcdefghijklmnopqrstuvwxyz1234567799 = 20;

8) An Identifier can start with.?
A) Alphabet.
B) Underscore ( _ ) sign.
C) Any character that can be typed on a keyboard.
D) Option A & Option B.

Explanation:
  • Identifier is just a name given to a Function, Variable etc.
  • Identifier name should contain only Letter, Numbers and Underscore.

9) C Programs are used in .?
A) Any Electronic device which works on some logic and Operating System.
B) Washing machine
C) Fridge, Microwave Ovens
D) All the above.

Explanation:
C is a fast-to-execute language that is also safe to use with microprocessors. C and C++ are used to write device drivers.

10) What are the types of Constants in C Language.?
A) Primary Constants.
B) Secondary Constants.
C) Basic Constants and Advanced Constants.
D) Primary Constants and Secondary Constants.

Explanation:
  • Integer (int), Floating Point (float), and Character are the primary constants (char).
  • Secondary Constants are Structure, Union, Array and Enum..

11) Choose correct statements.
A) A constant value does not change. A variable value can change according to needs.
B) A constant can change its values. A variable can have one constant value only.
C) There is no restriction on number of values for constants or variables.
D) Constants and Variables can not be used in a singe main function.

Explanation:
  • The value of a constant is always the same. Literal is another name for constant.
  • At any point in time, a variable can have any number of arbitrary values and only one value. Identifier is another name for variable.
12) Find an integer constant.
A) 3.145.
B) 34.
C) "125".
D) None of the above.

Explanation:
  • A whole or entire number without a decimal point is an integer constant. 3.14 is a real number or a floating point number.
13) Find a Floating Point constant.
A) 12.3E5
B) 12e34
C) 125.34857
D) All the above.

Explanation:
  • There are two ways to depict Floating Point.
  1. Fractional Form eg. 12345.67.
  2. Exponential Form (Mantissa)e(number) or (Mantissa)E(number) eg. 123.4567E2 (e2  = 10 power 2 = 100).
14) Find a Character constant.
A) 'A' 'a'
B) '1' '9'
C) '$' '#'
D) All the above.

Explanation:
  • Within Single Quotes, a character constant has only one character. In a keyboard, the Single Quote Double Quote Key is located beside the Enter Key. Simply said, it is a single quote that is correct.
  • This is what a left single quote looks like.
  • This is what a right single quote looks like:
15) Choose a right statement.
A) int myage = 10; int my_age = 10;
B) int myage = 10; int my,age = 10;
C) int myage = 10; int my age = 10;
D) All are right

Explanation:
  • In a variable name, such as an identifier name, only the underscore ( ) symbol is permitted. 
  • There are no spaces, commas, or other special characters allowed.

16) Number of Keywords present in C Language are .?
A) 32
B) 34
C) 62
D) 64

Explanation:
  • Originally, there were only 32 keywords. Individual companies can include and use additional keywords if necessary. These keywords should be preceded by .
eg. __mykeyword

17) Each statement in a C program should end with.?
A) Semicolon ;
B) Colon :
C) Period . (dot symbol)
D) None of the above.

Explanation:
int amount = 20;
float x,y;

18) Choose a correct statement.
A) C Compiler converts your C program into machine readable language.
B) C Editor allows you to type C Programs. It is just like a Notepad with extra options.
C) Console shows the output of a C Program if it is text output.
D) All the above

Post a Comment

Previous Post Next Post