C Programming and Problem Solving
Questions 141 to 150
141.
|
char *ptr;
char myString[] = “abcdefg”;
ptr = myString;
ptr += 5;
what string does ptr point to in the sample code above?
|
||||||||||
Which
one of the following will declare a pointer to an integer at address 0x200 in
memory?
|
|||||||||||
x
= 3, counter = 0;
while ((x-1))
{
++counter;
x--;
}
Referring
to the sample code above, what value will the variable counter have when
completed?
|
|||||||||||
What is the result of the following code?
x=0;
switch(x) { case 1: cout<<"One"; case 0: cout<<"Zero"; case 2: cout<<"Hello World"; }
|
|||||||||||
short testarray[4][3] = { {1}, {2,3}, {4,5,6}};
printf(“%d\n”, sizeof(testarray));
Assuming a short is two bytes long, what will be printed by the
above code?
|
|||||||||||
Which
one of the following will read a character from the keyboard and will store
it in the variable c?
|
|||||||||||
What
does the “auto” specifier do?
|
|||||||||||
How
is a variable accessed from another file?
|
|||||||||||
Which
one of the following is valid for opening a read-only ASCII file?
|
|||||||||||
What
is the meaning of self-referential structure?
|
Answers
141.
|
Answer
: (a)
Reason: The code is executed the output of the
program is fg. Hence the answer is a
|
Answer
: (a)
Reason: int *x; *x=0x200 is the correct declaration
of a pointer to an integer at address 0x200 in memory
|
|
Answer
: (c)
Reason: the answer for the code is 2. hence the
choice is c
|
|
Answer
: (a)
Reason: the initial value of x is 0. so first case 0 will be executed ,
there is no break after the case 0 so next case 2 will be executed . Hence
the answer is a.
|
|
Answer
: (e)
Reason: the size of an array testarray is 24
|
|
Answer
: (e)
Reason: getchar() is the function it will read a
character from the keyboard
|
|
Answer
: (b)
Reason: Auto is a automatic storage class. The
purpose of auto is it indicates that a variable’s memory will automatically be preserved
|
|
Answer
: (a)
Reason: the global variable is referenced via the
extern specifier
|
|
Answer
: (e)
Reason: fopen(filename, “r”) is valid for opening a
read-only ASCII file
|
|
Answer
: (c)
Reason: The meaning of self referential structure is
a structure calling it’s parent structure
|
No comments :
Post a Comment