Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is the correct way to take input in C?
1) input()
2) get()
3) scanf()
4) cin>>
Answer : scanf()
Which of the following is a valid keyword in C?
1) input
2) None of the above
3) int
4) define
Answer : int
Which function is used to dynamically allocate memory in C?
1) calloc()
2) new()
3) malloc()
4) alloc()
Answer : malloc()
Which of the following is a relational operator in C?
1) =
2) *
3) <
4) +
Answer : <
How do you return a value from a function in C?
1) give value;
2) return value;
3) send value;
4) exit value;
Answer : return value;
What is the maximum value that can be stored in an unsigned int?
1) 65535
2) 32767
3) 2147483647
4) Depends on the system
Answer : Depends on the system
Which keyword is used to include external files in C?
1) import
2) #define
3) #include
4) use
Answer : #include
What does the following line of code do: int *ptr = &a;
1) Creates a pointer to a
2) Assigns the address of a to ptr
3) Both a and b
4) None of the above
Answer : Assigns the address of a to ptr
How do you declare a structure in C?
1) struct myStruct { int a; };
2) struct myStruct = { int a; };
3) structure myStruct { int a; };
4) None of the above
Answer : struct myStruct { int a; };
What is the correct way to use a function from a library in C?
1) Include the library and call the function
2) Just call the function
3) Declare the function
4) None of the above
Answer : Include the library and call the function