Q.1 A global variable is a variable
(A) declared in the main ( ) function.
(B) declared in any function other than the main ( ) function.
(C) declared outside the body of every function.
(D) declared any where in the C program.
Ans: C
A global variable is declared outside the body of every function.
Q.2 main ( ) is an example of
(A) library function
(B) user defined function
(C) header
(D) statement
Ans: A
main() is a special function used by C system to tell the computer where the program starts.
Q.3 While incrementing a pointer, its value gets increased by the length of the data type to which it points. This length is called
(A) scale factor
(B) length factor
(C) pointer factor
(D) increment factor
Ans: D
While incrementing a pointer, its value gets increased by the length of the data type to which it points.
Q.4 The first digit of a decimal constant must be
(A) a zero
(B) a non zero number
(C) a negative number
(D) an integer
Ans: D
Decimal constants consist of a set of digit, 0 to 9, preceded by an optional – or + sign.
Q.5 What is the output of the following statement:
printf (“%-3d”,12345);
(A) 1 2 3
(B) -1 2 3
(C) 1 2 3 4 5
(D) 12
Ans: C
printf statement would print 12345.
Q.6 A single character input from the keyboard can be obtained by using the function.
(A) printf ( )
(B) scanf ( )
(C) putchar ( )
(D) getchar ( )
Ans: D
Reading a single character can be done by using the function getchar( ).
Q.7 The function ftell ( )
(A) reads a character from a file
(B) reads an integer from a file
(C) gives the current position in the file
(D) sets the position to the beginning of the file.
Ans: C
ftell( ) takes a file pointer and returns a number of type long, that corresponds to the current position.
Q.8 If the variables i, j and k are assigned the values 5,3 and 2 respectively, then the expression i = j + ( k + + = 6 ) + 7
(A) gives an error message
(B) assigns a value 16 to i
(C) assigns a value 18 to i
(D) assigns a value 19 to i
Ans: A
It gives an error message-Lvalue required.
Q.9 If an integer needs two bytes of storage, then the maximum value of a signed integer is
(A) 216-1
(B) 215-1
(C) 216
(D) 215
Ans: B
If we use a 16 bit word length, the size of the integer value is limited to the range -215 to 215-1
Q.10 Literal means
(A) a string
(B) a string constant
(C) a character
(D) an alphabet
Ans: B
Literal means a string constant.
Q.11 If ‘y’ is of integer type then the expressions
3* (y − 8)/9 and (y − 8)/9 * 3
(A) must yield the same value.
(B) must yield different values.
(C) may or may not yield the same value.
(D) none of the above.
Ans: C
The expression may or may not yield the same value.
Q.12 In the following code fragment
int x, y = 2, z, a;
x=(y*=2) + (z=a=y);
printf (‘%d’,x);
(A) prints 8
(B) prints 6
(C) prints 6 or 8 depending on the compiler
(D) is syntactically wrong
Ans: A
It will print 8 because x=(y*=2)+(z=a=y)=4+4=8.
Q.13 A possible output of the following program fragment is
for (i=getchar();; i=get.char())
if (i==‘x’) break;
else putchar(i);
(A) mi
(B) mix
(C) mixx
(D) none of the above
Ans: D
None of the above as it is wrong syntax.
Q.14 In a for loop, if the condition is missing, then,
(A) It is assumed to be present and taken to be false.
(B) It is assumed to be present and taken to be true.
(C) It results in a syntax error.
(D) Execution will be terminated abruptly.
Ans: B
Q.15 If storage class is missing in the array definition, by default it will be taken to be
(A) automatic
(B) external
(C) static
(D) either automatic or external depending on the place of occurrence.
Ans: A
A variable declared inside inside a function without storage class specification is, by default, an automatic variable.
Q.16 The maximum number of dimensions an array can have in C is
(A) 3
(B) 4
(C) 5
(D) compiler dependent
Ans: D
C allows arrays of three or more dimensions. The exact limit is determined by the compiler.
Q.17 puts(argv[0]);
(A) prints the name of the source code file.
(B) prints argv.
(C) prints the number of command line arguments.
(D) prints the name of the executable code file.
Ans: D
argv[0] represent the filename where the executable code of the program is stored.
Q.18 printf(“%–10s”, “ABDUL”); displays
(A) ABDULbbbbb
(B) bbbbbABDUL
(C) ABDULbbbbbbbbbb
(D) bbbbbbbbbbABDUL
Ans: A
-10s will print ABDUL in 10 space ABDUL followed by 5 blank space.
Q.19 Which amongst the following expression uses bitwise operator?
(A) a++
(B) !a>5
(C) a|b
(D) a!=b
Ans: C
| is bitwise OR.
Q.20 The output of the following program is
main( )
{ float y;
y=198.7361;
printf(“%7.2f”, y);
}
(A) 1 9 8 . 7 3 6
(B) 1 9 8 . 7 3
(C) 1 9 8 . 7 4
(D) 1 9 8 . 7 4
Ans: C
The printf statement is giving formatted output till two places of decimal.
Read articles, Questions and answers, Multiple choice questions, GATE Previous years questions papers with answer key, UGC-NET Old question papers with answer key about Computer Science and Information Technology
Monday, October 05, 2020
C programming and Data structure
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Open Researcher and Contributor ID (ORCID)