McqMate
Chapters
1. |
Which of the following is not a valid variable name declaration? |
A. | int __a3; |
B. | int __3a; |
C. | int __A3; |
D. | None of the mentioned |
Answer» D. None of the mentioned |
2. |
Which of the following is not a valid variable name declaration? |
A. | int _a3; |
B. | int a_3; |
C. | int 3_a; |
D. | int _3a |
Answer» C. int 3_a; |
3. |
Why do variable names beginning with the underscore is not encouraged? |
A. | It is not standardized |
B. | To avoid conflicts since assemblers and loaders use such names |
C. | To avoid conflicts since library routines use such names |
D. | To avoid conflicts with environment variables of an operating system |
Answer» C. To avoid conflicts since library routines use such names |
4. |
All keywords in C are in ____________ |
A. | LowerCase letters |
B. | UpperCase letters |
C. | CamelCase letters |
D. | None of the mentioned |
Answer» A. LowerCase letters |
5. |
Variable name resolution (number of significant characters for the uniqueness of variable) depends on ___________ |
A. | Compiler and linker implementations |
B. | Assemblers and loaders implementations |
C. | C language |
D. | None of the mentioned |
Answer» A. Compiler and linker implementations |
6. |
Which of the following is not a valid C variable name? |
A. | int number; |
B. | float rate; |
C. | int variable_count; |
D. | int $main; |
Answer» D. int $main; |
7. |
Which of the following is true for variable names in C? |
A. | They can contain alphanumeric characters as well as special characters |
B. | It is not an error to declare a variable to be one of the keywords(like goto, static) |
C. | Variable names cannot start with a digit |
D. | Variable can be of any length |
Answer» C. Variable names cannot start with a digit |
8. |
What is short int in C programming? |
A. | The basic data type of C |
B. | Qualifier |
C. | Short is the qualifier and int is the basic data type |
D. | All of the mentioned |
Answer» C. Short is the qualifier and int is the basic data type |
9. |
The format identifier ‘%i’ is also used for _____ data type. |
A. | char |
B. | int |
C. | float |
D. | double |
Answer» B. int |
10. |
Which data type is most suitable for storing a number 65000 in a 32-bit system? |
A. | signed short |
B. | unsigned short |
C. | long |
D. | int |
Answer» B. unsigned short |
11. |
Which of the following is a User-defined data type? |
A. | typedef int Boolean; |
B. | typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays; |
C. | struct {char name[10], int age}; |
D. | all of the mentioned |
Answer» D. all of the mentioned |
12. |
What is the size of an int data type? |
A. | 4 Bytes |
B. | 8 Bytes |
C. | Depends on the system/compiler |
D. | Cannot be determined |
Answer» C. Depends on the system/compiler |
13. |
enum types are processed by _________ |
A. | Compiler |
B. | Preprocessor |
C. | Linker |
D. | Assembler |
Answer» A. Compiler |
14. |
Which of the following statement is false? |
A. | Constant variables need not be defined as they are declared and can be defined later |
B. | Global constant variables are initialized to zero |
C. | const keyword is used to define constant values |
D. | You cannot reassign a value to a constant variable |
Answer» A. Constant variables need not be defined as they are declared and can be defined later |
15. |
Which of the following declaration is not supported by C? |
A. | String str; |
B. | char *str; |
C. | float str = 3e2; |
D. | Both String str; & float str = 3e2; |
Answer» A. String str; |
16. |
Which of the following declaration is illegal? |
A. | char *str = “string Contents”; |
B. | char str[] = “string Contents””; |
C. | char str[20] = “string Contents””; |
D. | char[] str = “string Contents””; |
Answer» D. char[] str = “string Contents””; |
17. |
Which keyword is used to prevent any changes in the variable within a C program? |
A. | immutable |
B. | mutable |
C. | const |
D. | volatile |
Answer» C. const |
18. |
Which of the following is not a pointer declaration? |
A. | char a[10]; |
B. | char a[] = {‘1’, ‘2’, ‘3’, ‘4’}; |
C. | char *str; |
D. | char a; |
Answer» D. char a; |
19. |
Which of the following statement is false? |
A. | A variable defined once can be defined again with different scope |
B. | A single variable cannot be defined with two different types in the same scope |
C. | A variable must be declared and defined at the same time |
D. | A variable refers to a location in memory |
Answer» C. A variable must be declared and defined at the same time |
20. |
A variable declared in a function can be used in main(). |
A. | True |
B. | False |
C. | True if it is declared static |
D. | None of the mentioned |
Answer» B. False |
21. |
What is the precedence of arithmetic operators (from highest to lowest)? |
A. | %, *, /, +, – |
B. | %, +, /, *, – |
C. | +, -, %, *, / |
D. | %, +, -, *, / |
Answer» A. %, *, /, +, – |
22. |
Which of the following is not an arithmetic operation? |
A. | a * = 10; |
B. | a / = 10; |
C. | a ! = 10; |
D. | a % = 10; |
Answer» C. a ! = 10; |
23. |
Which of the following data type will throw an error on modulus operation(%)? |
A. | char |
B. | short |
C. | int |
D. | float |
Answer» D. float |
24. |
Which among the following are the fundamental arithmetic operators, i.e, performing the desired operation can be done using that operator only? |
A. | +, – |
B. | +, -, % |
C. | +, -, *, / |
D. | +, -, *, /, % |
Answer» A. +, – |
25. |
Are logical operator sequence points? |
A. | True |
B. | False |
C. | Depends on the compiler |
D. | Depends on the standard |
Answer» A. True |
26. |
Do logical operators in the C language are evaluated with the short circuit? |
A. | True |
B. | False |
C. | Depends on the compiler |
D. | Depends on the standard |
Answer» A. True |
27. |
What is the result of logical or relational expression in C? |
A. | True or False |
B. | 0 or 1 |
C. | 0 if an expression is false and any positive number if an expression is true |
D. | None of the mentioned |
Answer» B. 0 or 1 |
28. |
Relational operators cannot be used on ____________ |
A. | structure |
B. | long |
C. | strings |
D. | float |
Answer» A. structure |
29. |
Which among the following is NOT a logical or relational operator? |
A. | != |
B. | == |
D. | = |
Answer» D. = |
30. |
What is the type of the following assignment expression if x is of type float and y is of type int? y = x + y; |
A. | int |
B. | float |
C. | there is no type for an assignment expression |
D. | double |
Answer» A. int |
31. |
What will be the value of the following assignment expression? (x = foo())!= 1 considering foo() returns 2 |
A. | 2 |
B. | True |
C. | 1 |
D. | 0 |
Answer» A. 2 |
32. |
Operation “a = a * b + a” can also be written as ___________ |
A. | a *= b + 1; |
B. | (c = a * b)!=(a = c + a); |
C. | a = (b + 1)* a; |
D. | All of the mentioned |
Answer» D. All of the mentioned |
33. |
What will be the final value of c in the following C statement? (Initial value: c = 2) c <<= 1; |
A. | c = 1; |
B. | c = 2; |
C. | c = 3; |
D. | c = 4; |
Answer» D. c = 4; |
34. |
In expression i = g() + f(), first function called depends on __________ |
A. | Compiler |
B. | Associativiy of () operator |
C. | Precedence of () and + operator |
D. | Left to write of the expression |
Answer» A. Compiler |
35. |
Which operators of the following have same precedence? P. "!=", Q. "+=", R. "<<=" |
A. | P and Q |
B. | Q and R |
C. | P and R |
D. | P, Q and R |
Answer» B. Q and R |
36. |
Comment on the following statement n = 1; printf("%d, %dn", 3*n, n++); |
A. | Output will be 3, 2 |
B. | Output will be 3, 1 |
C. | Output will be 6, 1 |
D. | Output is compiler dependent |
Answer» D. Output is compiler dependent |
37. |
Which is correct representation of C statement? e = a * b + c / d * f; |
A. | e = (a * (b +(c /(d * f)))); |
B. | e = ((a * b) + (c / (d * f))); |
C. | e = ((a * b) + ((c / d)* f)); |
D. | Both e = ((a * b) + (c / (d * f))); and e = ((a * b) + ((c / d)* f)); |
Answer» D. Both e = ((a * b) + (c / (d * f))); and e = ((a * b) + ((c / d)* f)); |
38. |
While swapping 2 no’ what at precautions to be taken care? b = (b / a); a = a * b; b = a / b; |
A. | Data type should be either of short, int and long |
B. | Data type should be either of float and double |
C. | All data types are accepted except for (char *) |
D. | This code doesn’t swap 2 numbers |
Answer» B. Data type should be either of float and double |
39. |
function tolower(c) defined in library <ctype.h> works for ___________ |
A. | Ascii character set |
B. | Unicode character set |
C. | Ascii and utf-8 but not EBCDIC character set |
D. | Any character set |
Answer» D. Any character set |
40. |
Which type of conversion is NOT accepted? |
A. | From char to int |
B. | From float to char pointer |
C. | From negative int to char |
D. | From double to char |
Answer» B. From float to char pointer |
41. |
Which of the following type-casting have chances for wrap around? |
A. | From int to float |
B. | From int to char |
C. | From char to short |
D. | From char to int |
Answer» B. From int to char |
42. |
Which of the following typecasting is accepted by C? |
A. | Widening conversions |
B. | Narrowing conversions |
C. | Widening & Narrowing conversions |
D. | None of the mentioned |
Answer» C. Widening & Narrowing conversions |
43. |
When do you need to use type-conversions? |
A. | The value to be stored is beyond the max limit |
B. | The value to be stored is in a form not supported by that data type |
C. | To reduce the memory in use, relevant to the value |
D. | All of the mentioned |
Answer» D. All of the mentioned |
44. |
What is the scope of an external variable? |
A. | Whole source file in which it is defined |
B. | From the point of declaration to the end of the file in which it is defined |
C. | Any source file in a program |
D. | From the point of declaration to the end of the file being compiled |
Answer» D. From the point of declaration to the end of the file being compiled |
45. |
What is the scope of a function? |
A. | Whole source file in which it is defined |
B. | From the point of declaration to the end of the file in which it is defined |
C. | Any source file in a program |
D. | From the point of declaration to the end of the file being compiled |
Answer» D. From the point of declaration to the end of the file being compiled |
46. |
In the standard library of C programming language, which of the following header file is designed for basic mathematical operations? |
A. | math.h |
B. | conio.h |
C. | dos.h |
D. | stdio.h |
Answer» A. math.h |
47. |
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ? |
A. | rem = 3.14 % 2.1; |
B. | rem = modf(3.14, 2.1); |
C. | rem = fmod(3.14, 2.1); |
D. | Remainder cannot be obtain in floating point division. |
Answer» C. rem = fmod(3.14, 2.1); |
48. |
By default a real number is treated as a |
A. | A.float |
B. | B.double |
C. | C.long double |
D. | D. far double |
Answer» B. B.double |
49. |
Which among the following is the odd one out? |
A. | printf |
B. | fprintf |
C. | putchar |
D. | scanf |
Answer» D. scanf |
50. |
For a typical program, the input is taken using _________ |
A. | scanf |
B. | Files |
C. | Command-line |
D. | All of the mentioned |
Answer» D. All of the mentioned |
51. |
What does the following command line signify? prog1 prog2 |
A. | It runs prog1 first, prog2 second |
B. | It runs prog2 first, prog1 second |
C. | It runs both the programs, pipes output of prog1 to input of prog2 |
D. | It runs both the programs, pipes output of prog2 to input of prog1 |
Answer» C. It runs both the programs, pipes output of prog1 to input of prog2 |
52. |
What is the default return-type of getchar()? |
A. | char |
B. | int |
C. | char * |
D. | reading character doesn’t require a return-type |
Answer» B. int |
53. |
What is the value of EOF? |
A. | -1 |
B. | 0 |
C. | 1 |
D. | 10 |
Answer» A. -1 |
54. |
What is the use of getchar()? |
A. | The next input character each time it is called |
B. | EOF when it encounters end of file |
C. | The next input character each time it is called EOF when it encounters end of file |
D. | None of the mentioned |
Answer» C. The next input character each time it is called EOF when it encounters end of file |
55. |
Which of the following statement is true? |
A. | The symbolic constant EOF is defined in <stdio.h> |
B. | The value is -1 |
C. | The symbolic constant EOF is defined in <stdio.h> & value is -1 |
D. | Only value is -1 |
Answer» C. The symbolic constant EOF is defined in <stdio.h> & value is -1 |
56. |
What is the return value of putchar()? |
A. | The character written |
B. | EOF if an error occurs |
C. | Nothing |
D. | Both character written & EOF if an error occurs |
Answer» D. Both character written & EOF if an error occurs |
57. |
Escape sequences are prefixed with ________ |
A. | % |
B. | / |
C. | ” |
D. | None of the mentioned |
Answer» D. None of the mentioned |
58. |
What is the purpose of sprintf? |
A. | It prints the data into stdout |
B. | It writes the formatted data into a string |
C. | It writes the formatted data into a file |
D. | None of the mentioned |
Answer» B. It writes the formatted data into a string |
59. |
The syntax to print a % using printf statement can be done by ________ |
A. | % |
B. | \% |
C. | ‘%’ |
D. | %% |
Answer» D. %% |
60. |
What are the Properties of the first argument of a printf() functions? |
A. | It is defined by a user |
B. | It keeps the record of the types of arguments that will follow |
C. | There may no be first argument |
D. | None of the mentioned |
Answer» B. It keeps the record of the types of arguments that will follow |
61. |
Which of the following function with ellipsis are illegal? |
A. | void func(…); |
B. | void func(int, …); |
C. | void func(int, int, …); |
D. | none of the mentioned |
Answer» A. void func(…); |
62. |
Which of the following data-types are promoted when used as a parameter for an ellipsis? |
A. | char |
B. | short |
C. | int |
D. | none of the mentioned |
Answer» A. char |
63. |
Which header file includes a function for variable number of arguments? |
A. | stdlib.h |
B. | stdarg.h |
C. | ctype.h |
D. | both stdlib.h and stdarg.h |
Answer» A. stdlib.h |
64. |
Which of the following macro extracts an argument from the variable argument list (ie ellipsis) and advance the pointer to the next argument? |
A. | va_list |
B. | va_arg |
C. | va_end |
D. | va_start |
Answer» B. va_arg |
65. |
The type va_list in an argument list is used ________ |
A. | To declare a variable that will refer to each argument in turn; |
B. | For cleanup |
C. | To create a list |
D. | There is no such type |
Answer» A. To declare a variable that will refer to each argument in turn; |
66. |
In a variable length argument function, the declaration “…” can _______ |
A. | Appear anywhere in the function declaration |
B. | Only appear at the end of an argument list |
C. | Nothing |
D. | None of the mentioned |
Answer» B. Only appear at the end of an argument list |
67. |
Each call of va_arg _______ |
A. | Returns one argument |
B. | Steps va_list variable to the next |
C. | Returns one argument & Steps va_list variable to the next |
D. | None of the mentioned |
Answer» C. Returns one argument & Steps va_list variable to the next |
68. |
The standard header _______ is used for variable list arguments (…) in C. |
A. | <stdio.h > |
B. | <stdlib.h> |
C. | <math.h> |
D. | <stdarg.h> |
Answer» D. <stdarg.h> |
69. |
What is the purpose of va_end? |
A. | Cleanup is necessary |
B. | Must be called before the program returns |
C. | Cleanup is necessary & Must be called before the program returns |
D. | None of the mentioned |
Answer» C. Cleanup is necessary & Must be called before the program returns |
70. |
Which of the following is NOT a delimiter for an input in scanf? |
A. | Enter |
B. | Space |
C. | Tab |
D. | None of the mentioned |
Answer» D. None of the mentioned |
71. |
If the conversion characters of int d, i, o, u and x are preceded by h, it indicates? |
A. | A pointer to int |
B. | A pointer to short |
C. | A pointer to long |
D. | A pointer to char |
Answer» B. A pointer to short |
72. |
Which of the following doesn’t require an & for the input in scanf()? |
A. | char name[10]; |
B. | int name[10]; |
C. | float name[10]; |
D. | all of the mentioned |
Answer» A. char name[10]; |
73. |
Which of the following is an invalid method for input? |
A. | scanf(“%d%d%d”,&a, &b, &c); |
B. | scanf(“%d %d %d”, &a, &b, &c); |
C. | scanf(“Three values are %d %d %d”,&a,&b,&c); |
D. | none of the mentioned |
Answer» D. none of the mentioned |
74. |
Which of the following represents the function for scanf()? |
A. | void scanf(char *format, …) |
B. | int scanf(char *format, …) |
C. | char scanf(int format, …) |
D. | char *scanf(char *format, …) |
Answer» B. int scanf(char *format, …) |
75. |
What does scanf() function return? |
A. | Number of successfully matched and assigned input items |
B. | Nothing |
C. | Number of characters properly printed |
D. | Error |
Answer» A. Number of successfully matched and assigned input items |
76. |
The conversion characters d, i, o, u, and x may be preceded by h in scanf() to indicate? |
A. | A pointer to short |
B. | A pointer to long |
C. | Nothing |
D. | Error |
Answer» A. A pointer to short |
77. |
The syntax of printf() function is printf(“control string”, variable list) ;what is the prototype of the control string? |
A. | %[flags][.precision][width][length]specifier |
B. | %[flags][length][width][.precision]specifier |
C. | %[flags][width][.precision][length]specifier |
D. | %[flags][.precision][length][width]specifier |
Answer» C. %[flags][width][.precision][length]specifier |
78. |
The parameter control string in the printf () is a C String that contains text to be __________ |
A. | taken from a standard output device |
B. | written on to the standard output device |
C. | received from the standard output device |
D. | nothing can be said |
Answer» B. written on to the standard output device |
79. |
Output justification such as decimal point, numerical sign, trailing zeros or octal are specified. |
A. | specifier |
B. | flags |
C. | precision |
D. | decimal |
Answer» B. flags |
80. |
What symbol is used to Left-justify within the data given field width? |
A. | -(minus sign) |
B. | +(plus sign) |
C. | # |
D. | 0 |
Answer» A. -(minus sign) |
81. |
What specifies the minimum number of characters to print after being padded with zeros or blank spaces? |
A. | flags |
B. | length |
C. | width |
D. | precision |
Answer» C. width |
82. |
The maximum number of characters to be printed is specified by __________ |
A. | precision |
B. | width |
C. | length |
D. | flags |
Answer» A. precision |
83. |
________is used to define the type and the interpretation of the value of the corresponding argument. |
A. | precision |
B. | specifiers |
C. | flags |
D. | decimal |
Answer» B. specifiers |
84. |
A conversion specification %7.4f means ____________ |
A. | print a floating point value of maximum 7 digits where 4 digits are allotted for the digits after the decimal point |
B. | print a floating point value of maximum 4 digits where 7digits are allotted for the digits after the decimal point |
C. | print a floating point value of maximum 7 digits |
D. | print a floating point value of minimum 7 digits where 4 digits are allotted for the digits after the decimal point |
Answer» A. print a floating point value of maximum 7 digits where 4 digits are allotted for the digits after the decimal point |
85. |
Choose the correct description for control string %-+7.2f. |
A. | – means display the sign, + means left justify, 7 specifies the width and 2 specifies the precision |
B. | – means left justify, + means display the sign, 7 specifies the width and 2 specifies the precision |
C. | – means display the sign, + means left justify, 7 specifies the precision and 2 specifies the width |
D. | – means left justify, + means display the sign, 7 specifies the precision and 2 specifies the width |
Answer» B. – means left justify, + means display the sign, 7 specifies the width and 2 specifies the precision |
86. |
What error is generated on placing an address operator with a variable in the printf statement? |
A. | compile error |
B. | run-time error |
C. | logical error |
D. | no error |
Answer» B. run-time error |
87. |
If by mistake you specify more number of arguments, the excess arguments will ____________ |
A. | be ignored |
B. | produce compile error |
C. | produce run-time error |
D. | produce logical error |
Answer» A. be ignored |
88. |
What happens when zero flag is used with left justification? |
A. | data is padded with zeros |
B. | zero flag is ignored |
C. | data is padded with blank spaces |
D. | will give error |
Answer» B. zero flag is ignored |
89. |
For floating point numbers, the precision flag specifies the number of decimal places to be printed. When no precision modifier is specified, printf() prints _______ |
A. | six decimal positions |
B. | five decimal positions |
C. | four decimal positions |
D. | three decimal positions |
Answer» A. six decimal positions |
90. |
What will the given code result in printf(“\n you are\”awesome \" ");? |
A. | compile error |
B. | run-time error |
C. | you are "awesome" |
D. | you are awesome |
Answer» C. you are "awesome" |
91. |
What will be the output for the given code printf(“\n The number is %07d”,1212); |
A. | The number is 0001212 |
B. | The number is 1212 |
C. | The number is 1212 |
D. | The number is 1212000 |
Answer» A. The number is 0001212 |
92. |
The syntax of the scanf() is scanf(“control string “, arg1,arg2,arg3,….,argn); the prototype of control string is ____________ |
A. | [=%[width][modifiers]type=] |
B. | [=%[modifiers][width]type=] |
C. | [=%[width] [modifiers]] |
D. | [width][modifiers] |
Answer» A. [=%[width][modifiers]type=] |
93. |
What is the use of symbol * in the control string as shown [=%[*][width] [modifiers] type=]? |
A. | * is optional and used when the data should be read from the stream but ignored |
B. | * is not optional, used to read data from the stream but it is not ignored |
C. | * is not optional, it is used to read data stream but ignored |
D. | * is optional and used to read data from stream but it is not ignored |
Answer» A. * is optional and used when the data should be read from the stream but ignored |
94. |
What action is carried out by scanf if a user enters any blank spaces, tabs, and newlines? |
A. | consider as input |
B. | ignores it |
C. | produces error |
D. | nothing can be said |
Answer» B. ignores it |
95. |
What error will generate if the read and write parameters are not separated by commas? |
A. | run-time error |
B. | compile error |
C. | logical error |
D. | no error |
Answer» B. compile error |
96. |
_____ is an optional argument that gives the maximum number of characters to be read. |
A. | modifiers |
B. | width |
C. | precision |
D. | length |
Answer» B. width |
97. |
Explain the format string "%5d%s %c" |
A. | five characters as a decimal integer, then reads the remaining as a string and then scans the first non-whitespace character |
B. | compile error |
C. | run-time error |
D. | read first five characters as a decimal and ignore the rest |
Answer» A. five characters as a decimal integer, then reads the remaining as a string and then scans the first non-whitespace character |
98. |
Select the correct value of i from given options i=scanf("%d %d", &a, &b); |
A. | 1 |
B. | 2 |
C. | 3 |
D. | No value assigned |
Answer» B. 2 |
99. |
If the user enters 1 3.2 s, what value will be returned by the scanf()?scanf("%d %f %c", &s1, &s2, &s3); |
A. | 1 |
B. | 2 |
C. | 3 |
D. | No return value |
Answer» C. 3 |
100. |
If the user enters 1 s 3.2, what value will be returned by the scanf()?scanf("%d %f %c", &a, &b, &c); |
A. | 1 |
B. | 2 |
C. | 3 |
D. | no return value |
Answer» A. 1 |
Done Reading?