Write the output of : (2) a = 8 b = a++ c = a + b + c print ( a , b , c )
Answers
Answer:
What will be the output of the below program?
#include <stdio.h>
int main()
{
printf("%d", printf("%d", printf("%d", printf("%s", "Welcome to geeksforgeeks"))));
return (0);
}
Options:
1. Welcome to geeksforgeeks2531
2. Welcome to geeksforgeeks2421
3. Welcome to geeksforgeeks2124
4. Welcome to geeksforgeeks3125
The answer is option(2).
Explanation : As we all know that the printf function returns the numbers of character that is going to print and scanf function returns the number of input given.
2. What will be the output of the following program?
#include <stdio.h>
int main()
{
int x = 30, y = 25, z = 20, w = 10;
printf("%d ", x * y / z - w);
printf("%d", x * y / (z - w));
return (0);
}
Options:
1. 27 85
2. 82 27
3. 27 75
4. No output
The output is option(3).
Explanation : In the above program, precedence takes the advantage. Therefore In the statement compiler first calculate x*y then / and after that subtraction.