AmbitionBox

Discover Best Places to work in India

C Programming

C Programming Questions and Answers

Showing 51 - 60 of 103 questions

51

What will be the output of the program?

# define P printf("%d\n", -1^~0);#define M(P) int main()\
             {\
                P\
                return0;\
             }
M(P)
a

1

b

0

c

-1

d

2

correct answer b
Answer :

Option B

52

What will be the output of the program ?

#include < stdio . h >int main()
{
    int i=32, j=0x20, k, l, m;
    k=i|j;
    l=i&j;
    m=k^l;
    printf("%d, %d, %d, %d, %d\n", i, j, k, l, m);
    return0;
}
a

0, 0, 0, 0, 0

b

0, 32, 32, 32, 32

c

32, 32, 32, 32, 0

d

32, 32, 32, 32, 32

correct answer c
Answer :

Option C

53

What will be the output of the program?

#include < stdio . h >int main()
{
    printf("%d %d\n", 32<<1, 32<<0);
    printf("%d %d\n", 32<<-1, 32<<-0);
    printf("%d %d\n", 32>>1, 32>>0);
    printf("%d %d\n", 32>>-1, 32>>-0);
    return0;
}
a

Garbage values

b

64 32
0 32
16 32
0 32

c

All zeros

d

8 0
0 0
32 0
0 16

correct answer b
Answer :

Option B

54

What will be the output of the program?

#include < stdio . h >int main()
{
    unsignedint res;
    res = (64 >>(2+1-2)) & (~(1<<2));
    printf("%d\n", res);
    return0;
}
a

32

b

64

c

0

d

128

correct answer a
Answer :

Option A

55

What will be the output of the program ?

#include < stdio . h >int main()
{
    int i=4, j=8;
    printf("%d, %d, %d\n", i|j&j|i, i|j&&j|i, i^j);
    return0;
}
a

4, 8, 0

b

1, 2, 1

c

12, 1, 12

d

0, 0, 0

correct answer c
Answer :

Option C

56

Which header file should be included to use functions like malloc() and calloc()?

a

memory.h

b

stdlib.h

c

string.h

d

dos.h

correct answer b
Answer :

Option B

57

What will be the output of the program?

#include < stdio . h >#include < stdlib . h >int main()
{
    int *p;
    p = (int *) malloc (20); /* Assume p has address of 1314 */free(p);
    printf("%u", p);
    return0;
}
a

1314

b

Garbage value

c

1316

d

Random address

correct answer a
Answer :

Option A

58

What will be the output of the program (16-bit platform)?

#include < stdio . h >#include < stdlib . h >int main()
{
    int *p;
    p = (int *) malloc (20);
    printf("%d\n", sizeof (p));
    free(p);
    return0;
}
a

4

b

2

c

8

d

Garbage value

correct answer b
Answer :

Option B

59

What will be the output of the program?

#include < stdio . h >#includeint main()
{
    char *s;
    char *fun();
    s = fun();
    printf("%s\n", s);
    return0;
}
char *fun()
{
    char buffer[30];
    strcpy(buffer, "RAM");
    return (buffer);
}
a

0xffff

b

Garbage value

c

0xffee

d

Error

correct answer b
Answer :

Option B

Explanation :

The output is unpredictable since buffer is an auto array and will die when the control go back to main. Thus s will be pointing to an array , which not exists.

60

Assume integer is 2 bytes wide. What will be the output of the following code?

#include < stdio . h >#include < stdlib . h >#define MAXROW 3#define MAXCOL 4int main()
{
    int (*p)[MAXCOL];
    p = (int (*) [MAXCOL]) malloc( MAXROW *sizeof (*p));
    printf("%d, %d\n", sizeof(p), sizeof(*p));
    return0;
}
a

2, 8

b

4, 16

c

8, 24

d

16, 32

correct answer a
Answer :

Option A

Select a company to compare with

vs

Similar Companies