Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Home
»
C Programming
»
Library Functions
What will be the output of the program? #include
int main() { int i; i = scanf("%d %d", &i, &i); printf("%d\n", i); return 0; }
1
2
Garbage value
Error: cannot assign scanf to variable
Correct Answer:
2
Explanation:
scanf()
returns the number of variables to which you are provding the input.
i = scanf("%d %d", &i, &i);
Here Scanf() returns 2. So
i
= 2.
printf("%d\n", i);
Here it prints 2.
← Previous Question
Next Question→
More Questions from
Library Functions
What will be the output of the program? #include
#include
int main() { float i = 2.5; printf("%f, %d", floor(i), ceil(i)); return 0; }
What will function gcvt() do?
What will be the output of the program? #include
int main() { int i; i = printf("How r u\n"); i = printf("%d\n", i); printf("%d\n", i); return 0; }
What will be the output of the program? #include
int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'b' */ ungetc(c, stdout); printf("%c", c); ungetc(c, stdin); } return 0; }
What will be the output of the program? #include
int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'a' */ printf("%c", c); ungetc(c, stdin); } return 0; }
What will be the output of the program? #include
#include
int main() { char *i = "55.555"; int result1 = 10; float result2 = 11.111; result1 = result1+atoi(i); result2 = result2+atof(i); printf("%d, %f", result1, result2); return 0; }
Discussion & Comments
No comments yet. Be the first to comment!
Name:
Comment:
Post Comment
Join Discussion
Discussion & Comments