Knowee
Questions
Features
Study Tools

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.     }

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the given C code will be 15.

Here's the step by step explanation:

  1. The integer variable 'a' is declared and initialized with the value 10.
  2. The double variable 'b' is declared and initialized with the value 5.6.
  3. The integer variable 'c' is declared.
  4. 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'.
  5. The value of 'c' is printed which is 15.

This problem has been solved

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?

1/4

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.