Thursday, July 29, 2010

C Question Set 1-5


Question 1

The number of  components in a doubly linked list is



1

2

3

4



Question 2

What is the  output of the program?



#include  <stdio.h>

void main()

{

unsigned short  a = -4; // Assume short is 2 bytes

printf("\n  %u", a);

}



Error:  Variable of type unsigned char cannot store negative values

4

-4

65532





Question 3

Which of the  following is a non-linear data structure?



Stack

Queue

Linked List

Tree





Question 4

Function time  (time_t*) is used to get the



current system  time

time taken for  the program to execute

file updation  time

file creation  time





Question 5

Macros



Expands the  code size

Perform dumb  substitution

Reduce the  speed of program execution

Both A and B





Question 6

Which of the  options helps the programmer in debugging a program?



Watch

Building a  project

Conditional  compilation

Both A and C





Question 7

How can you  correct improper naming of function?



By type  defining the function

By declaring  pointer to functions

By # defining  the name

By redefining  the function





Question 8

Memory  conservation is possible using



Unions

Static  variables

Arrays

Bit fields





Question 9

What is the  output of the program?



#include  <stdio.h>

#define MAX 20

void main()

{

printf("%d",  ++MAX));

}



No error,  output is 20

No error,  output is 21

Error: Define  directive needs an identifier

Error: Lvalue  required





Question 10

What is the  output of the program?



#include  <stdio.h>

#define SQ(a)  a*a



void main()

{

printf("%d",  SQ(2+3));

}



11

25

Error in  compilation

13





Question 11

'C' language  was developed to achieve



Portability

Modularity

Platform  independence

Reusability





Question 12

How many bytes  are allocated for "int" declaration?



minimum 2

only 2

minimum 4

only 4





Question 13

Which of the  following data types has the same size irrespective of the operating system?



char*

int

float

char





Question 14

What is the  output of the program?



#include  <stdio.h>

void main()

{

int m = (m =  1, m++, --m);

printf("\n  %d ", m);

}



Error:  undefined symbol 'm'

2

1

3





Question 15

What is the  output of the program?



#include  <stdio.h>

void main()

{

printf("%d",  sizeof(int) ? 1 ? 2 : 3 ? 4 : 5);

}



Error: Lvalue  required

syntax error:  missing : before )

2

3





Question 16

A switch  statement is similar to



while

do - while

multiple if -  else if - else

for





Question 17

Which of the  following function returns an integer data type?



strncpy

strcmp

strstr

strcat





Question 18

Which of the  following statements is correct?



when a pointer  is incremented by 1 the address contained in the pointer is incremented by 1

when a pointer  is incremented by 1 the address contained in the pointer is incremented by size  of integer

when a pointer  is incremented by 1 the address contained in the pointer is incremented  according to the type of pointer

when a pointer  is incremented by 1 the address contained in the pointer is incremented  according to the type it is pointing to





Question 19

What is the  output of the program?



#include  <stdio.h>

void main()

{

static int a[]  = {5, 10, 15, 20};

int* ptr = a;

int** ptr_ptr  = &ptr;

printf("\n  %d",**ptr_ptr++);

}



5

10

15

20





Question 20

The compiler  evaluates the operator '*' as either a pointer indirection or multiplication  based on



the operator  precedence

the number of  operands

the type of  operands

its location  in the source code





Answers

Answer 1 - C

Answer 2 - D

Answer 3 - D

Answer 4 - A

Answer 5 - D

Answer 6 - D

Answer 7 - B

Answer 8 - D

Answer 9 - D

Answer 10 - A

Answer 11 - A

Answer 12 - A

Answer 13 - D

Answer 14 - C

Answer 15 - B

Answer 16 - C

Answer 17 - B

Answer 18 - C

Answer 19 - A

Answer 20 - B

No comments:

Post a Comment