Question 10Tag to RevisitWhat will be the output of the following C code?1. #include <stdio.h>2. int main()3. {4. int a = 10;5. double b = 5.6;6. int c;7. c = a + b;8. printf("%d", c);9. }
Question
Question 10Tag to RevisitWhat will be the output of the following C code?1. #include <stdio.h>2. int main()3. {4. int a = 10;5. double b = 5.6;6. int c;7. c = a + b;8. printf("%d", c);9. }
Solution
The output of the given C code will be 15.
Here's the step by step explanation:
- The integer variable 'a' is declared and initialized with the value 10.
- The double variable 'b' is declared and initialized with the value 5.6.
- The integer variable 'c' is declared.
- The sum of 'a' and 'b' is calculated. Since 'b' is a double, the sum would be a double too. But since 'c' is an integer, the decimal part of the sum (0.6) will be truncated and only the integer part (15) will be stored in 'c'.
- The value of 'c' is printed which is 15.
Similar Questions
What will be the output of the following C code?
Question 10Tag to RevisitWhat will be the output of the following C code?1. #include <stdio.h>2. int main()3. {4. int a = 10;5. double b = 5.6;6. int c;7. c = a + b;8. printf("%d", c);9. }
what will be the output of the c program?
Suppose that in a C program snippet, followings statements are used
What will be the output of the following C++ code?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.