AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C Programming
What will be the output of the program?
# define P printf("%d\n", -1^~0);#define M(P) int main()\ {\ P\ return0;\ } M(P)
1
0
-1
2
Option B
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; }
0, 0, 0, 0, 0
0, 32, 32, 32, 32
32, 32, 32, 32, 0
32, 32, 32, 32, 32
Option C
#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; }
Garbage values
64 320 3216 320 32
All zeros
8 00 032 00 16
#include < stdio . h >int main() { unsignedint res; res = (64 >>(2+1-2)) & (~(1<<2)); printf("%d\n", res); return0; }
32
64
128
Option A
#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; }
4, 8, 0
1, 2, 1
12, 1, 12
0, 0, 0
Which header file should be included to use functions like malloc() and calloc()?
memory.h
stdlib.h
string.h
dos.h
#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; }
1314
Garbage value
1316
Random address
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; }
4
8
#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); }
0xffff
0xffee
Error
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.
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; }
2, 8
4, 16
8, 24
16, 32
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies