1. Q. What is a difference between a declaration and a definition of a variable? Choice 1
Both can occur multiple times, but a declaration must occur first. Choice 2
There is no difference between them. Choice 3
A definition occurs once, but a declaration may occur many times. Choice 4
A declaration occurs once, but a definition may occur many times. [Ans] Choice 5
Both can occur multiple times, but a definition must occur first. 2. "My salary was increased by 15%!"
Select the statement which will EXACTLY print the line of text above. Choice 1
printf("\"My salary was increased by 15/%\!\"\n"); Choice 2
printf("My salary was increased by 15%!\n"); Choice 3
printf("My salary was increased by 15'%'!\n"); Choice 4
printf("\"My salary was increased by 15%%!\"\n");[Ans] Choice 5
printf("\"My salary was increased by 15'%'!\"\n"); 3.
int a=10,b; b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);
what will be the output when following code is executed Choice 1
12,10,11,13 Choice 2 22,10,11,13 Choice 3 22,11,11,11 Choice 4 12,11,11,11 Choice 5
22,13,13,13[Ans] 4. #define MAX_NUM 15
MAX_NUM is an integer variable. Choice 2
MAX_NUM is a linker constant. Choice 3
MAX_NUM is a precompiler constant. Choice 4
MAX_NUM is a preprocessor macro. [Ans] Choice 5
MAX_NUM is an integer constant. 5. int x = 2 * 3 + 4 * 5;
What value will x contain in the sample code above? Choice 1
22 Choice 2 26[Ans] Choice 3 46 Choice 4 50 Choice 5 70
6. How is a variable accessed from another file? Choice 1
The global variable is referenced via the extern specifier.[Ans] Choice 2
The global variable is referenced via the auto specifier. Choice 3
The global variable is referenced via the global specifier. Choice 4
The global variable is referenced via the pointer specifier. Choice 5
The global variable is referenced via the ext specifier. 7. C is which kind of language?
Choice 1 Machine Choice 2
Procedural[Ans] Choice 3
Assembly Choice 4
Choice 5 Strictly-typed 8.
int x = 0;
for (x=1; x<4; x++); printf("x=%d\n", x);
What will be printed when the sample code above is executed? Choice 1
x=0 Choice 2 x=1 Choice 3 x=3 Choice 4 x=4[Ans] Choice 5 x=5 9.
int x = 3; if( x == 2 ); x = 0; if( x == 3 ) x++;
else x += 2;
What value will x contain when the sample code above is executed? Choice 1
1 Choice 2 2[Ans] Choice 3 3 Choice 4 4 Choice 5 5 10.
default : x += 1;
case '+' : x += y; /*It will go to all the cases*/ case '-' : x -= y;
}
After the sample code above has been executed, what value will the variable x contain? Choice 1
4 Choice 2 5 Choice 3 6 [Ans] Choice 4 7 Choice 5 8
11. In a C expression, how is a logical AND represented? Choice 1
@@ Choice 2 || Choice 3 .AND. Choice 4 && [Ans] Choice 5 .AND
12. How do printf()'s format specifiers %e and %f differ in their treatment of floating-point numbers?
Choice 1
%e always displays an argument of type double in engineering notation; %f always displays an argument of type double in decimal notation. [Ans]
Choice 2
%e expects a corresponding argument of type double; %f expects a corresponding argument of type float.
Choice 3
%e displays a double in engineering notation if the number is very small or very large. Otherwise, it behaves like %f and displays the number in decimal notation.
Choice 4
%e displays an argument of type double with trailing zeros; %f never displays trailing zeros. Choice 5
13. Which one of the following will read a character from the keyboard and will store it in the variable c?
Choice 1 c = getc(); Choice 2 getc( &c ); Choice 3
c = getchar( stdin ); Choice 4
getchar( &c ) Choice 5
c = getchar(); [Ans]
14. Which one of the following C operators is right associative? Choice 1
= [Ans] Choice 2 , Choice 3 [] Choice 4 ^ Choice 5
15. How do you include a system header file called sysheader.h in a C source file? Choice 1
#include <sysheader.h> [Ans] Choice 2
#incl "sysheader.h" Choice 3
#includefile <sysheader> Choice 4
#include sysheader.h Choice 5
#incl <sysheader.h>
16. Which one of the following printf() format specifiers indicates to print a double value in decimal notation, left aligned in a 30-character field, to four (4) digits of precision?
%-30.4f [Ans] decimal notation Choice 5
%#30.4f 17.
int x = 0; for ( ; ; ) {
if (x++ == 4) break; continue; }
printf("x=%d\n", x);
What will be printed when the sample code above is executed? Choice 1
x=0 Choice 2 x=1 Choice 3 x=4 Choice 4 x=5[Ans] Choice 5 x=6
18. According to the Standard C specification, what are the respective minimum sizes (in bytes) of the following three data types: short; int; and long?
Choice 1 1, 2, 2 Choice 2 1, 2, 4 Choice 3 1, 2, 8 Choice 4 2, 2, 4[Ans] Choice 5 2, 4, 8 19.
int i = 4; int x = 6; double z; z = x / i;
What will print when the sample code above is executed? Choice 1
z=0.00 Choice 2 z=1.00[Ans] Choice 3 z=1.50 Choice 4 z=2.00 Choice 5 z=NULL
20. When applied to a variable, what does the unary "&" operator yield? Choice 1
The variable's value Choice 2
The variable's binary form Choice 3
The variable's address [Ans] Choice 4
The variable's format Choice 5
The variable's right value
21. Which one of the following is NOT a valid identifier? Choice 1
__ident Choice 2 auto [Ans] Choice 3 bigNumber Choice 4 g42277 Choice 5
peaceful_in_space
22. short int x; /* assume x is 16 bits in size */
What is the maximum number that can be printed using printf("%d\n", x), assuming that x is initialized as shown above?
Choice 4 32,767 [Ans] Choice 5 65,536
23. What number is equivalent to -4e3? Choice 1
-4000 [Ans] Choice 2 -400 Choice 3 -40 Choice 4 .004 Choice 5 .0004
24. Q4. What will be the output of the following statements ? int a = 4, b = 7,c; c = a = = b; printf("%i",c);
a) 0 b) error c) 1 (ans) d) garbage value
25. Q 5. What will be the output of the following statements ? int a = 5, b = 2, c = 10, i = a>b;
void main()
{ printf("hello"); main(); } a) 1
b) 2
c) infinite number of times(ans) d) none of these
26. What will be the output of the following program ? #include
void main() { int a = 2; switch(a) { case 1:
continue; case 3: printf("bye"); }
}
a) error (Ans) b) goodbye c) bye