C Programming and Problem Solving Questions and Answers 201 to 210

C Programming and Problem Solving

Questions 201 to 210



201.
Identify the wrong expression for the given integer array ‘a’ as “int a[10];” [ In Turbo C compiler].
(a)
a[0]
(b)
a[-1]
(c)
a[10]
(d)
0[a]
(e)
++a;.
202.
What is the value of a[0][2] in int a[3][4]={{1,2},{3,4,5}};?
(a)
0
(b)
1
(c)
2
(d)
3
(e)
4.
203.
The parameters in a function definition are known as
(a)
Actual parameters
(b)
Arguments
(c)
Formal parameters
(d)
Dummy parameters
(e)
Optional parameters.
204.
The function used to position the file pointer in C is
(a)
fseekg()
(b)
seekg()
(c)
fileseek()
(d)
seekf()
(e)
fseek().
205.
int *p[5]; is used for
(a)
Fixed row size and varying column size
(b)
Fixed row size and fixed column size
(c)
Varying row size and varying column size
(d)
Varying row size and fixed column size
(e)
For storing integers.
206.
The declaration int (*a)[8]; is
(a)
An array of pointers
(b)
A pointer to an array
(c)
A pointer to a function
(d)
Function returning pointer
(e)
Function taking 8 integer pointers.
207.
What is the value of ‘f’ after execution of the following code?
float  f = 1/4.0 + 1/4;
(a)
0.00
(b)
0.75
(c)
0.50
(d)
0.25
(e)
1.0.
208.
What is the value of ‘ptr’ after the execution of the following code?
int *const ptr = 5;
Now if the address of ‘ptr’ is 2000, then ptr-- is
(a)
4
(b)
1999
(c)
1998
(d)
3
(e)
Invalid.
209.
To read the formatted input data from a file, which of the following function is used?
(a)
getchar()
(b)
fgets()
(c)
fscanf()
(d)
scanf()
(e)
fread().
210.
The arguments in main() function are known as
(a)
Program parameter
(b)
Command line arguments
(c)
Memory in line format conversion
(d)
Both (a) and (b) above
(e)
Both (b) and (c) above.

Answers


201.
Answer : (e)
Reason  :       The remaining option are valid in C, but the increment operation cannot be performed on array in C.
202.
Answer : (a)
Reason  :       As the remaining unassigned elements of the array are initialized with 0. So a[0][2] is first row’s third element which is zero.
203.
Answer : (c)
Reason  :       According to C terminology they are known as formal parameters and the operators in function call are known as actual parameters or arguments.
204.
Answer : (e)
Reason  :       The remaining all the options are not for the required operation on random accessing of files.
205.
Answer : (a)
Reason  :       Because it is an array of 5 integer pointers, where every integer pointer can point to integer quantities later on, may be of same or varying size.
206.
Answer : (b)
Reason  :       Whenever it is casted as (*a)[…] then it is always a pointer to array.
207.
Answer : (d)
Reason  :       1/4.0 is 0.25 and 1/4 is 0 only ( Because of integer division )
208.
Answer : (e)
Reason  :       As ‘ptr’ is a constant pointer and hence cannot be changed.
209.
Answer : (c)
Reason  :       scanf() is the function to read the formatted input data but from console, where as fscanf() is the function to read the formatted input data from the files.
210.
Answer : (d)
Reason  :       Because the Command line arguments and program parameters are same.


<< Prev 1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36...  Next >>


1 comment :