Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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() { 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,


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

0 Answers  


&#8206;#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   TCS,


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,






main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }

1 Answers  


Finding a number which was log of base 2

1 Answers   NetApp,


print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!

11 Answers   Wipro,


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

1 Answers  


main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } } a. 0, 0 b. 0, 513 c. 512, 0 d. 0, -513

3 Answers   HCL, Logical Computers,


write a c program to print magic square of order n when n>3 and n is odd?

1 Answers   HCL,


In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }

1 Answers  






Categories