Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
How do you access an element in a multidimensional array in C?
1) array[i][j]
2) array(i,j)
3) array[i,j]
4) array(i)(j)
Answer : array[i][j]
Which statement correctly increments a pointer in C?
1) ptr++
2) ++ptr*
3) ptr+
4) None of the above
Answer : ptr++
What is the result of the expression 4 & 5?
1) 0
2) 1
3) 4
4) 5
Answer : 4
Which keyword is used to create an alias for another data type in C?
1) typedef
2) alias
3) type
4) define
Answer : typedef
What will be the output of printf("%d", 10 >> 1);?
1) 5
2) 10
3) 20
4) Error
Answer : 5
Which of the following is true about a structure in C?
1) It can have functions as members.
2) It can have different data types as members.
3) It can only have integer data types.
4) None of the above
Answer : It can have different data types as members.
What is the correct way to declare an array of 10 integers in C?
1) int arr[10];
2) int arr();
3) int arr{10};
4) int arr[10];[]
Answer : int arr[10];
Which function is used to find the length of a string in C?
1) strlen()
2) strlength()
3) length()
4) size()
Answer : strlen()
What does the `sizeof` operator return when applied to a data type?
1) The size of the data type in bytes.
2) The address of the data type.
3) The maximum value of the data type.
4) None of the above
Answer : The size of the data type in bytes.
Which statement is used to include a standard library in C?
1) #include <stdio.h>
2) #include "stdio.h"
3) import stdio.h
4) using stdio.h
Answer : #include <stdio.h>