C Programming and Problem Solving Questions and Answers 301 to 310

C Programming and Problem Solving

Questions 301 to 310



301.
Which of the following puts program in the memory?
(a)  preprocessor    (b)  compiler            (c)  linker                 (d)  loader               (e)  editor.
302.
int z, x = 5, y = -10, a = 4, b = 2;
z = x++ - --y * b / a;
What number will z in the sample code above contain?
(a)  5                      (b)  6                       (c)  10                     (d)  11                     (e)  12.
303.
With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed?
(a)  unalloc()           (b)  dropmem()        (c)  dealloc()            (d)  release()            (e)  free().
304.
Which escape character can be used to begin a new line in C?
(a)  \a                     (b)  \n                      (c)  \l                       (d)  \m                     (e)  \t.
305.
char* myFunc (char *ptr)
{
ptr += 3;
return (ptr);
}
int main()
{
char *x, *y;
x = "HELLO";
y = myFunc (x);
printf ("y = %s \n", y);
return 0;
}
What is the output when the sample code above is executed?
(a)  y = HELLO        (b)  y = ELLO          (c)  y = LLO             (d)  y = LO              (e)  x = O.
306.
What is the associativity of the conditional operator
(a)  left to right        (b)  right to left        (c)  top to bottom   
(d)  bottom to top   (e)  left to left.
307.
What function will read a specified number of elements from a file?
(a)  fileread()           (b)  getline()             (c)  readfile()            (d)  fread()               (e)  gets().
308.
"My salary was increased by 15%!"
Select the statement which will EXACTLY reproduce the line of text above.
(a)   printf("\"My salary was increased by 15/%\!\"\n");
(b)   printf("My salary was increased by 15%!\n");
(c)   printf("My salary was increased by 15'%'!\n");
(d)   printf("\"My salary was increased by 15%%!\"\n");
(e)   printf("\"My salary was increased by 15'%'!\"\n");
309.
What is the difference between a declaration and a definition of a variable?
(a)   Both can occur multiple times, but a declaration must occur first
(b)   There is no difference between them
(c)   A definition occurs once, but a declaration may occur many times
(d)   A declaration occurs once, but a definition may occur many times
(e)   Both can occur multiple times, but a definition must occur first.
310.
What is the meaning of self-referential structure?
(a)   Array of structures
(b)   Single structure
(c)   Structure calling it’s parent structure
(d)   Structure calling another structure
(e)   list of structures.

Answers


301.
Answer : (d)
Reason : Loader puts the program into memory whereas others functionality is different.
302.
Answer : (c)
Reason : based on the hierarchy of operations in c 10 is the correct answer.
303.
Answer : (e)
Reason : Remaining all are irrelevant methods.
304.
Answer : (b)
Reason : \n is for new line character and \t for tab space and remaining are not appropriate.
305.
Answer : (d)
Reason : LO is the correct choice because when myfunc is called and hello is passed as an argument.
LO is extracted as address is increased by 3 bytes.
306.
Answer : (b)
Reason : Right to left is the correct associativity remaining all don’t match.
307.
Answer : (d)
Reason : free() is the correct method to read specified number of element s from a file.
308.
Answer : (d)
Reason : Choice d produces the required output.
309.
Answer : (a)
Reason : Remaining all are contradictory according to c language
310.
Answer : (c)
Reason : Self referential structure stands for  structure calling its parents structure but not array of structures, etc.,


<< 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 >>


2 comments :