Answer to Question #266590 in C for anubhav

Question #266590

 (b) What will be the output for the following program C code?

                        #include<stdio.h>

                        int main()

                       {

                              int x=15, b;

                              float c;

                                  b=x/2;

                                  c=x/4;

                                  x=x%2;

                              printf(“ %d %d %f ”, x, b, c);

                                 return 0;

                       }                  


1
Expert's answer
2021-11-16T00:46:04-0500

Output

1 7 3.000000


Explanation

x=x%2;

The value of x is 15. The modulus of 15 and 2 is 1. Therefore the final value of x will be 1.

b=x/2;

Since b and 2 are integers, 15 divided by 2 results to 7.

c=x/4;

Since c is a float and 4 is an integer, 15 divided by 4 result to 3.000000



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS