int main()
{
int x=10;
printf("x=%d, count of earlier print=%d",
x,printf("x=%d, y=%d",x,--x));
getch();

}
==================================================

returns error>> ld returned 1 exit status
===================================================
Does it have something to do with printf() inside another
printf().

Answers were Sorted based on User's Feedback



int main() { int x=10; printf("x=%d, count of earlier print=%d", ..

Answer / aditya lele

It does not return an error .
the output would be
x=9, y=9x=9, count of earlier print=8

HINT: try and understand the way printf evaluation works (right to left or left to right), also keep in mind when printf is called and what argument values are passed and when exactly is the data written to STDOUT

Is This Answer Correct ?    3 Yes 0 No

int main() { int x=10; printf("x=%d, count of earlier print=%d", ..

Answer / aditya lele

By the way the error that you are talking about is because
of the fact that your function has an integer return type
and you are not returning anything.
add a

return 0;

at the end before you close the main()

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Code Interview Questions

main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }

2 Answers   HP,


program to Reverse a linked list

12 Answers   Aricent, Microsoft, Ness Technologies,


main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(ā€œ%u %u %u %d \nā€,a,*a,**a,***a); printf(ā€œ%u %u %u %d \nā€,a+1,*a+1,**a+1,***a+1); }

2 Answers  


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }

1 Answers  






how to test pierrot divisor

0 Answers  


write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details

2 Answers   TCS,


Finding a number which was log of base 2

1 Answers   NetApp,


Write a program to print a square of size 5 by using the character S.

6 Answers   Microsoft,


typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }

1 Answers  


main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }

1 Answers  


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


Categories