C Control StatementsC FunctionsC ArrayC PointerC Dynamic MemoryC StringC MathC StructureC UnionC File HandlingC PreprocessorC Command LineC Misc |
C Mcqs questions
|
a. int $numeric_num = 10000;
b. int my numeric= 1000;
c. int numeric_num = 100000;
d. int numeric_num = 100,000;
The correct option is (c)
Explanation:
Space, comma and $ cannot be used in a variable name.
4. What is short int in C programming ?
a. The basic data type of C
b. Short is the qualifier and int is the basic data type
c. Qualifier
d. All of above
The correct option is b
Explanation: None
5. What is the output of the following program ?
|
int main() |
a) 3 5
b) 3 3
c) 5 5
d) 5 3
Correct Option : d
Explanation:
The above code snippet swaps 2 numbers in C.
6. How is an array initialized in C language??
a) int a[3] = {1, 2, 3};
b) int a[] = new int[3]
c) int a(3) = [1, 2, 3]
d) int a = {1, 2, 3};
correct option a
Explanation:
The correct way of initialization of an array is given in Option a.
7. What is the output of the following code snippet?
|
int main() |
a. 1
b. 4
c. 10
d. 20
correct option C
Explanation:
The code basically calculates the sum of all the elements in the array a[].
8. How is the 3rd element in an array accessed based on pointer notation?
a) *(a + 3)
b) *a + 3
c) *(*a + 3)
d) &(a + 3)
correct option a
Explanation:
a[3] is equivalent to *(a + 3) in pointer notation.
9. What is the output of the following code snippet?
|
void solve() { |
a. 30 10
b. 10 20
c. 20 10
d. 10 30
correct option d
Explanation:
This problem uses the concept of scopes. In the pair of {}, the variable third which is declared inside it is local to the block and takes preference over the global third. So it is printed first, and then the global third.
10. What is the output of the following code snippet?
|
void solve() { |
a. 20
b. 12
c. 24
d. 18
correct option a
Explanation:
The ++a operator follows the “change then use” rule. The a++ operator follows the “use then change” rule. Using these rules along with proper associativity we get the result of 20.