C Programming MCQ Questions | c interview questions
Introduction
In this article, you will find basic to most puzzled interview queries questions. This article is very useful for those who are preparing for an interview in IT company. Whether you are experienced or
HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) |
Rs. 31,490
1) What are the types of linkages in C programming language?
Internal
External and None.
External, Internal and None.
Internal and External.
⇒ Answer: (C) External, Internal and None.
2) Which of the following special symbol allowed in C programming language variable name?
_ (underscore)
- (hyphen)
| (pipeline)
* (asterisk)
⇒ Answer: (A) _ (underscore).
3) Which of the following statements should be used in C programming to obtain a remainder after dividing 4.14 by 2.3 ?
rem = fmod(3.14, 2.1);
rem = modf(3.14, 2.1);
rem = 3.14 % 2.1;
Remainder cannot be obtain in floating point division.
⇒ Answer: (A) rem = fmod(3.14, 2.1);
4) Which of the following is true for variable names in C programming language?
Variable can be of any length
Variable names cannot start with a digit
It is not an error to declare a variable to be one of the keywords(like goto, static)
They can contain alphanumeric characters as well as special characters.
⇒ Answer: (B) Variable names cannot start with a digit
5) Which of the following is not a valid C programming language variable name?
int $main;
int variable_count;
float rate;
int number;
⇒ Answer: (A) int $main;
6) What will be the output of the following C code?
#include <stdio.h>
int main()
{
printf("Hello World! %d \n", a);
return0;
}
Hello World!
Compile time error
Hello World! followed by a junk value
Hello World! a;
⇒ Answer: (B) Compile time error
Explanation: since a is used without declaring the variable a.
7) What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a =10000;
int a =34;
printf("Hello World! %d\n", a);
return0;
}
Hello World! followed by a junk value
Hello World! 1000
Hello World! 34
Compile time error
⇒ Answer: (D) Compile time error
Explanation: Since a is already defined, redefining variable a results in an error.
8) What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a =10000;
int a =34;
printf("Hello World! %d\n", a);
return0;
}
10
20
The program will have a runtime error
Compile time error
⇒ Answer: (A) Variable names Number and number are both distinct as C is case sensitive programming language.
9) What will be the output of the following C code?
#include <stdio.h>
int main()
{
int main =20;
printf("%d", main);
return0;
}
It will experience infinite looping
It will run without any error and prints 20
It will cause a run-time error
It will cause a compile-time error
⇒ Answer: (B) It will run without any error and prints 20
10) Which of the following is not a valid variable name declaration in C programming language?