AmbitionBox

Discover Best Places to work in India

C Programming

C Programming Questions and Answers

Showing 1 - 10 of 11 questions

1

What will be the output of the following program :

#include<stdio.h>
main()
{
	int a=555,b=*ptr,*ptr=&a;
        printf("%d %d %d",++a,--b,*ptr++);
}

a

Compile Error

b

555 554 555

c

556 554 555

d

557 554 555

correct answer a

Answer : Option A

2

What will be the output of the following program :

#include<stdio.h>void main()
{
	float val=5.75;
	  int *ptr=&val;
	  printf("%.2f %.2f",*(float *)ptr,val);
}

a

Compile Error

b

5.75 5.75

c

5.00 5.75

d

None of these

correct answer b

Answer : Option B

3

What will be the output of the following program :

#include<stdio.h>
main()
{
	int a=5u,*b,**c,***d,****e;
	  b=&a;
	  c=&b;
	  d=&c;
	  e=&d;
	  printf("%u %u %u %u",*b-5,**c-11,***d-6,65535+****e);
}

a

Compile Error

b

0 65530 65535 4

c

65530 65535 65539

d

0 -6 -1 -2

correct answer b

Answer : Option B

4

What will be the output of the following program :

#include<stdio.h>void main()
{
	int (*a)[5];
	printf("%d %d",sizeof(*a),sizeof(a));
}


a

Compile error

b

2 5

c

5 2

d

None of these

correct answer d

Answer : Option D

5

What will be output of following program?

 

#include<stdio.h>#include<string.h>int main()
{
    int register a;
    scanf("%d",&a);  // say a = 10
    printf("%d",a);
    return0;
}
a

10

b

Address

c

0

d

Compilation error

correct answer d

Answer : Option D

Explanation :

Register data type stores in CPU. So it has not any memory address. Hence we cannot write &a.

6

What will be the output of the following program :

#include<stdio.h>
main()
{
	int val=1234;
	int* ptr=&val;
	printf("%d %d",val,*ptr++);
}

a

1234 1234

b

1235 1235

c

1234 1235

d

1235 1234

correct answer a

Answer : Option A

7

In which header file is the NULL macro defined?

a

stdio.h

b

stddef.h

c

stdio.h and stddef.h

d

math.h

correct answer c

Answer : Option C

Explanation :

The macro "NULL" is defined in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h, and wchar.h.

8

What will be output of following program?

 

#include<stdio.h>#include<string.h>int main()
{
    int a,b,c,d;
    char *p = (char*)0;
    int *q = (int*q)0;
    float *r = (float*)0;
    double *s = 0;
    a = ( int)(p+1);
    b = ( int)(q+1);
    c = ( int)(r+1);
    d = ( int)(s+1);
    printf("%d %d %d %d",a,b,c,d);
    return0;
}
a

2 2 2 2

b

1 2 4 8

c

1 2 2 4

d

Compilation error

correct answer b

Answer : Option B

Explanation :

Address + 1 = next address

9

What will be output of following program?

 

#include<stdio.h>#include<string.h>int main()
{
    int a,b,c,d;
    char *p = (char*)0;
    int *q = (int*q)0;
    float *r = (float*)0;
    double *s = 0;
    a = ( int)(p+1);
    b = ( int)(q+1);
    c = ( int)(r+1);
    d = ( int)(s+1);
    printf("%d %d %d %d",a,b,c,d);
    return0;
}
a

2 2 2 2

b

1 2 4 8

c

1 2 2 4

d

Compilation error

correct answer b

Answer : Option B

Explanation :

Address + 1 = next address

10

What will be the output of the following program :

#include<stdio.h>
main()
{
	int val=1234;
	int* ptr=&val;
	printf("%d %d",++val,*ptr);
}

a

1234 1234

b

1235 1235

c

1234 1235

d

1235 1234

correct answer d

Answer : Option D

Select a company to compare with

vs

Similar Companies