Thursday, July 29, 2010

C Question Set 1-4


Question1
Reusability of code in C is supported by

Functions
Macros
Pointers
Files

Question 2
The entry point of the 'C' program is with

#include
main(int argc, char * argv)
c_main
MAIN()

Question 3
When a const variable is declared, it is stored

in RAM
in ROM
on heap
in CPU registers

Question 4
What is the output of the program?
#include <stdio.h>
int main(int argc, char *argv[])
{
printf(" %d", printf("Hello Genesis"));
return 0;
}

Hello Genesis
13 Hello Genesis
Hello Genesis 13
None of the above

Question 5
What is the output of the program?
#include <stdio.h>

void main()
{
printf("\n Hi" " %s ", "Genesis"" InSoft");
}

Hi %s Genesis InSoft
Hi Genesis
Hi Genesis InSoft
Hi %s Genesis InSoft
Question 6
What is the output of the program?
#include <stdio.h>
main()
{
switch (5)
{
case 5: printf(" 5 ");
default: printf(" 10 ");
case 6: printf(" 6 ");
}
}
5
5 10
5 10 6
5 6

Question 7
What is the output of the program?

#include <stdio.h>

void main()
{
int x = 9;
Continue: printf("\n Continue ");
if(!x)
goto gen;
gen: printf(" Genesis ");
}

Genesis
Continue Genesis
Continue
None of the above


Question 8
Which argument of function 'strncmp()' specifies number of characters to be compared?

first
second
third
fourth

Question 9
Which of the following is not a storage class in C?

Static
Register
Extern
Stack


Question 10
Which of the following 'return' statement is correct?

return, return;
return(1, 2, 3);
return(return 4);
(return 5, return 6);


Question 11
The second argument to fopen() function is?

char
const char *
int *
FILE *


Question 12
What is the data type of FILE?

integer
union
pointer
structure


Question 13
The first argument of fwrite function is typecast to

char *
FILE *
int *
void *


Question 14
Which of the following storage class variables cannot be used with pointers?

extern
static
register
Both A and C


Question 15
What is the output of the program?

#include <stdio.h>

void main()
{
int (*myprintf)(const char*, ...) = printf;
myprintf("Genesis InSoft Limited");
}

Genesis InSoft Limited
No output
Undefined symbol myprintf
Prototype mismatch

Question 16
What is the output of the program?

#include <stdio.h>

void main()
{
char buffer[10] = {"Genesis"};
printf(" %d ", &buffer[4]- (buffer));
}

3
4
0
Illegal pointer subtraction

Question 17
If "arr" is an array of 5 x 5 dimension, arr[2][4] is same as

**(a+3+4)
*(a+3)+*(a+4)
**(a+3)+4
*(*(a+2)+4)


Question 18
What is the significance of the free() function?

It erases the contents of any type and cleans the pointer
It places the memory address with the pointer in free store
It assigns the pointer a NULL value
It disables the memory address with the pointer


Question 19
The following statement is used in C for

char *ptr = (char*) malloc(Length);

For faster execution of programs
For reducing the code
For conservation of memory
Both A and B

Question 20
What is the output of the program?

#include <stdio.h>
#define sq(a) a * a

void main()
{
printf("%d", sq(3 + 2));
}

25
11
10
Compilation error


Answers
Answer 1 - A
Answer 2 - B
Answer 3 - B
Answer 4 - C
Answer 5 - C
Answer 6 - C
Answer 7 - B
Answer 8 - C
Answer 9 - D
Answer 10 - B
Answer 11 - B
Answer 12 - D
Answer 13 - D
Answer 14 - C
Answer 15 - A
Answer 16 - B
Answer 17 - D
Answer 18 - B
Answer 19 - C
Answer 20 - B

No comments:

Post a Comment