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 following program :
#include<stdio.h> main() { int a=555,b=*ptr,*ptr=&a; printf("%d %d %d",++a,--b,*ptr++); }
Compile Error
555 554 555
556 554 555
557 554 555
Answer : Option A
#include<stdio.h>void main() { float val=5.75; int *ptr=&val; printf("%.2f %.2f",*(float *)ptr,val); }
5.75 5.75
5.00 5.75
None of these
Answer : Option B
#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); }
0 65530 65535 4
65530 65535 65539
0 -6 -1 -2
#include<stdio.h>void main() { int (*a)[5]; printf("%d %d",sizeof(*a),sizeof(a)); }
Compile error
2 5
5 2
Answer : Option D
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; }
10
Address
0
Compilation error
Answer : Option DExplanation :Register data type stores in CPU. So it has not any memory address. Hence we cannot write &a.
#include<stdio.h> main() { int val=1234; int* ptr=&val; printf("%d %d",val,*ptr++); }
1234 1234
1235 1235
1234 1235
1235 1234
In which header file is the NULL macro defined?
stdio.h
stddef.h
stdio.h and stddef.h
math.h
Answer : Option CExplanation :The macro "NULL" is defined in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h, and wchar.h.
#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; }
2 2 2 2
1 2 4 8
1 2 2 4
Answer : Option BExplanation :Address + 1 = next address
#include<stdio.h> main() { int val=1234; int* ptr=&val; printf("%d %d",++val,*ptr); }
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