☰
×
Home
◈ Introduction
C - Data Types IQ
◈ C Data Type Tricky - I
◈ C Data Type Tricky - II
◈ C Data Type Tricky - III
◈ C Data Type Tricky - IV
◈ C Data Type Tricky - V
C - Operators IQ
◈ C Operators Tricky - I
◈ C Operators Tricky - II
◈ C Operators Tricky - III
Choose the Correct
◈ Choose the Correct Ans - I
◈ Choose the Correct Ans- II
◈ Choose the Correct Ans - III
◈ Choose the Correct Ans - IV
◈ Choose the Correct Ans - V
◈ Choose the Correct Ans - VI
Find Output - Tricky
◈ C Pgm Tricky Questions I
◈ C Pgm Tricky Questions II
◈ C Pgm Tricky Questions III
◈ C Pgm Tricky Questions IV
◈ C Pgm Tricky Questions V
◈ C Pgm Tricky Questions VI
◈ C Pgm Tricky Questions VII
◈ C Pgm Tricky Questions VIII
◈ C Pgm Tricky Questions IX
C - General IQ
◈ General C Questions I
◈ General C Questions II
◈ General C Questions III
◈ General C Questions IV
◈ General C Questions V
◈ General C Questions VI
◈ General C Questions VII
Home
About
Consulting
Training
Tutorial
Interview Questions
Contact
Interview Questions
C Tricky - Find Output
Home
C Interview Questions
◈ Introduction
C Data Types Tricky Questions
◈ C Data Type Tricky Questions I
◈ C Data Type Tricky Questions II
◈ C Data Type Tricky Questions III
◈ C Data Type Tricky Questions IV
◈ C Data Type Tricky Questions V
C Operators Interview Questions
◈ C Operators Tricky Questions I
◈ C Operators Tricky Questions II
◈ C Operators Tricky Questions III
Choose the Correct Answer
◈ Choose the Correct Answer I
◈ Choose the Correct Answer II
◈ Choose the Correct Answer III
◈ Choose the Correct Answer IV
◈ Choose the Correct Answer V
◈ Choose the Correct Answer VI
Find Output - Tricky C Program
◈ C Programs Tricky Questions I
◈ C Programs Tricky Questions II
◈ C Programs Tricky Questions III
◈ C Programs Tricky Questions IV
◈ C Programs Tricky Questions V
◈ C Programs Tricky Questions VI
◈ C Programs Tricky Questions VII
◈ C Programs Tricky Questions VIII
◈ C Programs Tricky Questions IX
General C Interview Questions
◈ General C Questions I
◈ General C Questions II
◈ General C Questions III
◈ General C Questions IV
◈ General C Questions V
◈ General C Questions VI
◈ General C Questions VII
C Programming Interview Questions
C Tricky Questions - Find Output III
« Prev
Next »
C Tricky Questions - Find Output
Program 41 static int i=50; int pri( int x) { static int i=2; // i--; return (i--); } main() { static int i=100; int k; while(pri(i)) { printf("%d \t",i); i--; } printf("\n"); } Program 42 int a() {printf("hello\n");} int b() {printf("hai\n");} int c() {printf("bye\n");} main() { int (*p[3]) (void); p[0]=a(); p[1]=b(); p[2]=c(); p[2](); //printf("%d\n",p[2]); } Program 43 main() { extern int i; i=498; printf("%d\n",i); } Program 44 struct st { char i; int j; }k; #pragma pack(2) struct st1 { char k; int o; }s; main() { printf("%d %d\n",sizeof(k),sizeof(s)); } Program 45 #include
union u { short int i; struct st { char a; char b; }q; struct st1{ char c; char d; }w; }u; main() { u.q.a=0x50; u.w.d=0x60; printf("%x %x\n",u.i,u.i); printf("%d\n",sizeof(u)); } Program 46 struct st { int a; }ab; main() { ab.a=5; printf("%d\n",ab.a); printf("%d\n",(&ab)->a); } Program 47 struct st { int st; }st; main() { st.st=5; printf("%d\n",st.st); } Program 48 main() { //int (*pf)(int, ...); int (*pf)(const char *, ...); pf=printf; printf("neominds ",pf("neominds\n")); pf("software\n"); } Program 49 main() { char a[10]="neominds"; char *p; p=a; printf("%s\n",p); p=p+3; printf("%s\n",p); } Program 50 #include
main() { int *p; printf("size==%d\n",sizeof(p)); } Program 51 #include
#include
#include
static jmp_buf buf; main() { volatile int b; b=3; //before if() u changing value of volatile it can't change the //value of b. if(setjmp(buf)!=0) { printf("b = %d\n",b); exit(0); //sleep(1); } b=5; longjmp(buf,1); } Program 52 #include
main() { struct node { int a; int b; int c; }; struct node s={3,5,6}; struct node *ptr=&s; printf("%d\n",*(int *)ptr); printf("%d\n",++*(int *)ptr);// value will be incremented } Program 53 #include
void f(char *); main() { f("123"); } void f(char a[]) { if(a[1]=='\0') return; f(a+1); f(a+1); printf("%c ",a[1]); printf("\n"); } Program 54 #include
main(int argc,char **argv) { if(argc==1) printf("error\n"); printf("%c ",*(argv[1]+1)); printf("%c ",(*(argv+1))[2]); printf("%c \n",argv[1][2]); } Program 55 #include
main() { unsigned char c; typedef struct name { long a; int b; long c; }r; r re={3,4,5}; r *na=&re; printf("%d",*(int*) ( (char*)na + (unsigned int) & (((struct name *)0)->b)) ); } Program 56 #include
int foo(int x,int n) { int val; val=1; if(n>0) { if(n%2==1) val=val*x; val=val*foo(x*x,n/2); } } main() { int r; r=foo(2,4); printf("%d\n",r); } Program 57 #include
void foo(int a,int b,...) { int j; int *ptr=&b; j=0; while(j
char i; void try1() { static char *ptr="abcde"; i=*ptr; printf("%c ",i); try2(++ptr); } void try2(char *t) { static char *pt; pt=t+strlen(t)-1; if(i!=*pt--) if(t!=pt) try1(); } main() { try1(); } Program 58 #include
main() { int a[5]={1,2,3,4,5}; int *ptr=(int *)(&a+1); printf("%d %d\n",*(a+1),*(ptr-1)); printf("%d %d\n",*(a+1),*(ptr)); } Program 59 #include
main() { double a[2][3]; printf("%d ",sizeof(a)); printf("%d ",sizeof(a[1])); printf("%d \n",sizeof(a[1][1])); } Program 60 #include
void foo(int b[][3]) { ++b; b[1][1]=9; } main() { int a[3][3]={{1,2,3},{4,5,6},{7,8,9}}; foo(a); printf("%d\n",a[2][1]); }
« Prev
Next »
Helpful Links
Sateeshkg Home
Interview Questions
Corporate Training
Recommended Books
Linux Consulting
Apply for Job Assistance
If you have any queries please email us at
info@motionzen.com