main()

{

int i=_l_abc(10);

printf("%d\n",--i);

}

int _l_abc(int i)

{

return(i++);

}

Answers were Sorted based on User's Feedback



main() { int i=_l_abc(10); printf("%d\n",--i); } int ..

Answer / susie

Answer :

9

Explanation:

return(i++) it will first return i and then increments. i.e.
10 will be returned.

Is This Answer Correct ?    7 Yes 1 No

main() { int i=_l_abc(10); printf("%d\n",--i); } int ..

Answer / rahulkulkarni

Post increment - perform operation first , then increment

In function call _l_abc its post increment, so after value 10 to be returned is decided , local variable i is increment , its i in function.

Variable i in _l_abc is different than i in main.

Post decrement : decrement first then perform operation.

In main its pre decrement , returned 10 is decremented to 9, then printed.

Now , unless compiler does not throw error of beginning function name with _ , 9 is printed.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Code Interview Questions

struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }

1 Answers  


main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }

1 Answers  


What are segment and offset addresses?

2 Answers   Infosys,


Write a program that find and print how many odd numbers in a binary tree

1 Answers  


void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }

1 Answers  






main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }

2 Answers   CSS, Wipro,


Which one is taking more time and why ? :/home/amaresh/Testing# cat time.c //#include <stdio.h> #define EOF -1 int main() { register int c; while ((c = getchar()) != EOF) { putchar(c); } return 0; } ------------------- WIth stdio.h:- :/home/amaresh/Testing# time ./time_header hi hi hru? hru? real 0 m4.202s user 0 m0.000s sys 0 m0.004s ------------------ Witout stdio.h and with #define EOF -1 =================== /home/amaresh/Testing# time ./time_EOF hi hi hru? hru? real 0 m4.805s user 0 m0.004s sys 0 m0.004s -- From above two case , why 2nd case is taking more time ?

0 Answers  


main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”

5 Answers   HCL,


Code for 1>"ascii to string" 2>"string to ascii"

1 Answers   Aricent, Global Logic,


main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }

2 Answers   Persistent,


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }

2 Answers  


Categories