Home
MCQS
C/C MCQ Quiz Hub
C Programming - MCQ Questions Set 4
Choose a topic to test your knowledge and improve your C/C skills
1. Presence of code like “s.t.b = 10” indicates ____
Syntax Error
Structure
double data type
An ordinary variable name
2. Which of the following uses structure?
Array of structures
Linked Lists
Binary Tree
All of the mentioned
3. What is the correct syntax to declare a function foo() which receives an array of structure in function?
void foo(struct *var);
void foo(struct *var[]);
void foo(struct var);
none of the mentioned
4. Presence of loop in a linked list can be tested by ________
Traveling the list, if NULL is encountered no loop exists
Comparing the address of nodes by address of every other node
Comparing the the value stored in a node by a value in every other node
None of the mentioned
5. Which option should be selected to work the following C expression? string p = "HELLO";
typedef char [] string;
typedef char *string;
typedef char [] string; and typedef char *string;
Such expression cannot be generated in C
6. Which of the given option is the correct method for initialization? typedef char *string;
*string *p = “Hello”;
string p = “Hello”;
*string p = ‘A’;
Not more than one space should be given when using typedef
7. Which of the following is false about typedef?
typedef follow scope rules
typedef defined substitutes can be redefined again. (Eg: typedef char a; typedef int a;)
You cannot typedef a typedef with other term
All of the mentioned
8. Which of the following may create problem in the typedef program?
;
printf/scanf
Arithmetic operators
All of the mentioned
9. typedef int (*PFI)(char *, char *)creates _________
type PFI, for pointer to function (of two char * arguments) returning int
error
type PFI, function (of two char * arguments) returning int
type PFI, for pointer
10. What is typedef declaration?
Does not create a new type
It merely adds a new name for some existing type
Does not create a new type, It merely adds a new name for some existing type
None of the mentioned
11. The size of a union is determined by the size of the ______
First member in the union
Last member in the union
Biggest member in the union
Sum of the sizes of all members
12. Members of a union are accessed as______
union-name.member
union-pointer->member
both union-name.member & union-pointer->member
none of the mentioned
13. Which of the following data types are accepted while declaring bit-fields?
char
float
double
none of the mentioned
14. Which of the following reduces the size of a structure?
union
bit-fields
malloc
none of the mentioned
15. Which of the following is not allowed?
Arrays of bit fields
Pointers to bit fields
Functions returning bit fields
None of the mentioned
16. Bit fields can only be declared as part of a structure.
FALSE
true
Nothing
Varies
17. Which among the following is the odd one out?
printf
fprintf
putchar
scanf
18. For a typical program, the input is taken using _________
scanf
Files
Command-line
All of the mentioned
19. What does the following command line signify? prog1|prog2
It runs prog1 first, prog2 second
It runs prog2 first, prog1 second
It runs both the programs, pipes output of prog1 to input of prog2
It runs both the programs, pipes output of prog2 to input of prog1
20. What is the default return-type of getchar()?
char
int
char *
reading character doesn’t require a return-type
21. What is the value of EOF?
-1
0
1
10
22. What is the use of getchar()?
The next input character each time it is called
EOF when it encounters end of file
The next input character each time it is called EOF when it encounters end of file
None of the mentioned
23. Which of the following statement is true?
The symbolic constant EOF is defined in <stdio.h>
The value is -1
The symbolic constant EOF is defined in <stdio.h> & value is -1
Only value is -1
24. What is the return value of putchar()?
The character written
EOF if an error occurs
Nothing
Both character written & EOF if an error occurs
25. Which is true about function tolower?
The function tolower is defined in <ctype.h>
Converts an uppercase letter to lowercase
Returns other characters untouched
None of the mentioned
26. putchar(c) function/macro always outputs character c to the _____
screen
standard output
depends on the compiler
depends on the standard
27. The statement prog < infile causes _____
prog to read characters from infile
prog to write characters to infile
infile to read characters from prog instead
nothing
28. What is the difference between %e and %g?
%e output formatting depends on the argument and %g always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional
%e always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional and output formatting depends on the argument
No differences
Depends on the standard
29. Escape sequences are prefixed with ____
%
/
”
None of the mentioned
30. What is the purpose of sprintf?
It prints the data into stdout
It writes the formatted data into a string
It writes the formatted data into a file
None of the mentioned
31. The syntax to print a % using printf statement can be done by ____
%
\%
‘%’
%%
32. Which of the following function with ellipsis are illegal?
void func(…);
void func(int, …);
void func(int, int, …);
none of the mentioned
33. Which of the following data-types are promoted when used as a parameter for an ellipsis?
char
short
int
none of the mentioned
34. Which header file includes a function for variable number of arguments?
stdlib.h
stdarg.h
ctype.h
both stdlib.h and stdarg.h
35. Which of the following macro extracts an argument from the variable argument list (ie ellipsis) and advance the pointer to the next argument?
va_list
va_arg
va_end
va_start
36. The type va_list in an argument list is used _____
To declare a variable that will refer to each argument in turn;
For cleanup
To create a list
There is no such type
37. In a variable length argument function, the declaration “…” can _____
Appear anywhere in the function declaration
Only appear at the end of an argument list
Nothing
None of the mentioned
38. Each call of va_arg ____
Returns one argument
Steps va_list variable to the next
Returns one argument &amp; Steps va_list variable to the next
None of the mentioned
39. What are the first and second arguments of fopen?
A character string containing the name of the file &amp; the second argument is the mode
A character string containing the name of the user &amp; the second argument is the mode
A character string containing file pointer &amp; the second argument is the mode
None of the mentioned
40. For binary files, a ___ must be appended to the mode string.
Nothing
“b”
“binary”
“01”
41. What will fopen will return, if there is any error while opening a file?
Nothing
EOF
NULL
Depends on compiler
42. What is the return value of getc()?
The next character from the stream is not referred by file pointer
EOF for end of file or error
Nothing
None of the mentioned
43. When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?
Standard input
Standard output
Standard error
All of the mentioned
44. In C language, FILE is of which data type?
int
char *
struct
None of the mentioned
45. What is meant by ‘a’ in the following C operation? fp = fopen("Random.txt", "a");
Attach
Append
Apprehend
Add
46. Which of the following mode argument is used to truncate?
a
f
w
t
47. Which type of files can’t be opened using fopen()?
.txt
.bin
.c
none of the mentioned
48. Which of the following fopen() statements are illegal?
fp = fopen(“abc.txt”, “r”);
fp = fopen(“/home/user1/abc.txt”, “w”);
fp = fopen(“abc”, “w”);
none of the mentioned
49. What does the following segment of C code do? fprintf(fp, "Copying!");
It writes “Copying!” into the file pointed by fp
It reads “Copying!” from the file and prints on display
It writes as well as reads “Copying!” to and from the file and prints it
None of the mentioned
50. What is FILE reserved word?
A structure tag declared in stdio.h
One of the basic data types in c
Pointer to the structure defined in stdio.h
It is a type name defined in stdio.h
Submit