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

void main() { printf(“sizeof (void *) = %d \n“, sizeof( void *)); printf(“sizeof (int *) = %d \n”, sizeof(int *)); printf(“sizeof (double *) = %d \n”, sizeof(double *)); printf(“sizeof(struct unknown *) = %d \n”, sizeof(struct unknown *)); }

1 Answers  


void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

2 Answers  


main() { int i; clrscr(); printf("%d", &i)+1; scanf("%d", i)-1; } a. Runtime error. b. Runtime error. Access violation. c. Compile error. Illegal syntax d. None of the above

1 Answers   HCL,


main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }

1 Answers  


How to return multiple values from a function?

7 Answers  






#define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }

4 Answers   Google, HCL, Quick Heal, WTF,


Write a Program that Inputs 10 Numbers in an Array and Show the Maximum Number

2 Answers   Ace Info,


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 Answers  


Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

16 Answers   Aricent, Cisco, Directi, Qualcomm,


How can you relate the function with the structure? Explain with an appropriate example.

0 Answers  


How to swap two variables, without using third variable ?

104 Answers   AB, ADP, BirlaSoft, Cisco, Cygnet Infotech, HCL, Hewitt, Honeywell, HP, IBM, Infosys, Manhattan, Microsoft, Mobius, Percept, Satyam, SofTMware, TCS, Wipro, Yamaha,


Categories