A blog by Devendra Tewari
See answers below.
Pointer arguments are passed to a function by
a. Value
b. Reference
c. Global variable
d. Static variable
To pass an array as a parameter to a function, we pass it by
a. Value
b. Static variable
c. Global variable
d. Reference
Portability in C is
a. The ability to run the executable of one system in another
b. The ability to compile successfully the same source code in different systems
c. The fact that both the systems have, possibly incompatible, C compilers
The sizes of char
, int
and float
are, respectively
a. 2, 4, and 8 bytes
b. 1, 2, and 4 bytes
c. 1, 2, and 2 bytes
d. 2, 4, and 4 bytes
Structures and Unions are equivalent
a. True
b. False
A structure and a union, both have the same members. Then
a. The structure occupies less space than the union.
b. The union occupies less space than the structure.
c. Both occupy equal space.
The amount of space allocated in bytes for union cmplx {float x,float y,int i};
is
a. 4
b. 2
c. 10
d. 6
The maximum positive value that can be stored in a long
is
a. 2^32 - 1
b. 2^16 - 1
c. 2^(32-1) - 1
d. 2^(16-1) - 1
High precision scientific calculations involving a space expedition are being performed. The preferred data type must probably be
a. long
b. float
c. unsigned
d. double
printf("The world\n\0is round");
will display the message
a. The world
b. The world is round
c. The world
is round
If you want to read a string of words you can use the function
a. scanf
b. getch
c. gets
d. getchar
double
is used instead of float
because
a. float has less significant digits
b. double has a large mantissa
c. double has a smaller exponent
d. Both a and b
if var
is a variable then &var
is its
a. pointer
b. value
c. type
d. inverse
If ptr
is a pointer and val
is a variable, which of the following is a valid indirection
a. ptr = val;
b. ptr = *val;
c. &ptr = val;
d. ptr = &val;
If arr[10]
is an array of int
then which of the following accesses array index 1
a. printf("%d", 1[arr]);
b. printf("%d", *(arr+=1));
c. printf("%d", arr[1]);
d. all of the above
e. only a and c above
The string "hello world"
needs how many bytes for storage
a. 11
b. 13
c. 12
d. 10
The last byte of the string "Internet is big"
is
a. EOL
b. 0
c. 'g'
d. EOF
The result of 255 & 16
is
a. 255
b. 0
c. 020
d. 0x8
The result of 19%3
is
a. 6
b. 18
c. 0
d. 1
A header file is
a. a machine code file
b. a file containing source code of library functions
c. a file containing prototype declarations
d. both b and c
A register variable is mostly used for
a. loops and counters
b. passing parameters to functions
c. calling interrupt service routines
d. saving registers to stack
The first step in generation of executable file from C file is
a. Compiling
b. Linking
c. Pre-processing
d. Loading
To access a variable declared in another module of a big program we use storage class
a. auto
b. static
c. register
d. extern
When a file is opened, the file descriptor is assigned by
a. the compiler
b. the operating system
c. the user
d. the loader
To redirect stdout to a file, the function that may be used is
a. open
b. fopen
c. creat
d. freopen
The default value returned by a function having no prototype is assumed by ANSI C to be
a. void
b. char
c. int
d. float
In ANSI C, the generic pointer type is
a. pointer to void
b. pointer to char
c. pointer to int
d. pointer to float
Macro definitions in C are done by
a. #if
b. #include
c. const
d. #define
If a local variable must remember its previous value in a function it must be declared using the class
a. auto
b. extern
c. register
d. static
sizeof
is a
a. C library function
b. Reserved word
c. Operator
d. Both b and c
h
is a pointer to pointer to int
and points to p
, a pointer to int
. If p
points to a value 4
then *h
is
a. the int
4
b. the address of p
c. the address of h
d. the address of value 4
To dynamically allocate 100 locations each of type double
which of the following is correct
a. calloc(100,8)
b. calloc(8,100)
c. (double *)malloc(100)
d. calloc(800)
Which of the following are reserved words
a. static
b. while
c. return
d. all of the above
C was originally developed by
a. Ken Thompson and Dennis Ritchie
b. Dennis Ritchie and Brian Kernighan
c. Ken Thompson and Brian Kernighan
d. Niklaus Wirth and Dennis Ritchie
Variables can begin with
a. Underscore
b. Digit
c. Hyphen
d. None of the above
The value of a-b
, assuming a=0x0A
and b=012
is
a. 2
b. -2
c. 0
d. none of the above
Variables are initialized to zero for storage classes
a. Auto and Static
b. Extern and Static
c. Static and Register
d. Register and Auto
The output resulting from i=10; printf("%d --- %d",i,i++);
is
a. 10 --- 11
b. 10 --- 10
c. 11 --- 10
d. 11 --- 11
For char c=127; printf("%d",++c);
the output is
a. 128
b. 127
c. 0
d. -128
For int a=30*1000+2768; printf("%d",a);
the output is
a. 0
b. 1
c. -1
d. None of the above
For int a=244; if(a=400) printf("50th Independence Day");
a. The output is 50th Independence Day
b. There will be no output because a is not 400
if('X' < 'x'); printf("50th Independence Day");
a. The output is 50th Independence Day
b. There will be no output
Which is the odd one out
a. a++
b. a+=1
c. a=+1
d. a=a+1
for(;;)
a. is an illegal statement
b. is legal but the result is unpredictable
c. is illegal in ANSI C but legal in Turbo C
d. is legal and the result is predictable
Which of the following is not a C keyword
a. switch
b. case
c. choice
d. break
int i; char c;
then which of the following is lossless
a. i=c;c=i;
b. c=i;i=c;
if p
and q
are two pointers then which of the following is illegal
a. p=q
b. p-q
c. p+q
d. p=q+1
Values assigned to enum constants cannot be the same i.e. enum colors {BLUE=1,RED=1,GREEN=1,CYAN=2,MAGENTA=2,YELLOW=2}
is invalid
a. True
b. False
In int (*a)[13]
a. a
is a pointer
b. a
is an integer
c. a
is an array
d. a
is a function
a[i][j]
is same as
a. a+i+j
b. &((a+i)+j)
c. *(*(a+i)+j)
d. None of the above
If p
is a pointer, which of the following is invalid
a. p[-2]
b. p-2
c. p*2
d. p=0
In functions using C calling convention, stack cleanup is done by
a. Called function
b. Calling function
c. Operating system
In functions using Pascal calling convention, stack cleanup is done by
a. Called function
b. Calling function
c. Operating system
Which of the following is not true
a. Variable declarations allocate storage for variables
b. Variable definitions allocate storage for variables
Which of the following is not recursion
a. f1 calling f2 and f2 calling f1
b. f1 calling itself
c. main calling main
d. all of the above are recursion
Select the odd one
a. a+a+a+a
b. a<<2
c. a*4
d. a>>4
What is the size in bytes of the value 23L + 32U
a. 2
b. 4
c. 8
d. none of the above
Operator *
when used with pointers is called the
a. indirection operator
b. referencing operator
For declaration int (*a)[10];
and assuming a=100
, the output for printf("%p",a+1);
is
a. 102
b. 104
c. 120
d. 110
Which of the following is invalid
a. int a[2][2] = { {11, 12}, {21, 22} };
b. int a[][2] = { {11, 12}, {21, 22} };
c. int a[2][] = { {11, 12}, {21, 22} };
d. both b and c above
For char *s = "SNAIL"; (*(s+5))?printf("SNAIL"):printf("HARE");
the output is
a. SNAIL
b. HARE
If s
is a struct and p
a pointer to it, so that p=&s
then which of the following is the correct way to read a field fieldname
in the struct
a. p.fieldname
b. (*p).fieldname
c. s->fieldname
d. all of the above
If we have an executable program prog.exe
, and text file f1 then typing prog < f1
at DOS prompt means
a. The screen is temporarily redundant
b. The keyboard is temporarily redundant
c. Both screen and keyboard are temporarily redundant
d. The command is illegal
Which of the following are standard files in C
a. stdprn
b. stdout, stdin and stderr
c. stdaux
d. all of the above
Which of the following is not a valid function in C
a. cscanf
b. sscanf
c. fscanf
d. pscanf
With which of the following file I/O type is the buffer management transparent
a. high level
b. low level
To which of the following file I/O level do fwrite
and fread
belong
a. high level
b. low level
The statement #define NULL 0
is in the header file
a. conio.h
b. stdio.h
c. file.h
d. limits.h
Given enum days = {mon,tue,wed,thu,fri,sat,sun}
The output of printf("%d",mon+sun);
is
a. 7
b. 6
c. 8
d. none of the above
In C convention, the order of passing multiple parameters to a function occurs from
a. left to right with first parameter on top of stack
b. right to left with first parameter on top of stack
c. left to right with last parameter on top of stack
d. right to left with last parameter on top of stack
Consider the following piece of code if(i = 10 > 5); printf("%d",i);
The output is
a. 0
b. 1
c. Garbage value
d. None of the above
1a 2d 3b 4b 5b 6b 7a 8c 9d 10a 11c 12d 13a 14d 15e 16c 17b 18c 19d 20c 21a 22c 23d 24b 25d 26c 27a 28d 29d 30d 31d 32a 33d 34b 35a 36c 37b 38c 39d 40d 41a 42a 43c 44d 45c 46a 47c 48b 49a 50c 51c 52b 53a 54a 55d 56d 57b 58a 59c 60c 61b 62b 63b 64d 65d 66a 67a 68b 69b 70b 71b