What will be the output of the following program int i 6 j


What will be the output of the following program. int i = 6, j = 7, k = 8; float a = 6.78; i = a; j =2 * a; k = 2 *i; printf (\"i=%d j=%d, k=%d\", i, j, k);

Solution

#include<stdio.h>
int main()
{
int i = 6, j = 7, k = 8;
float a = 6.78;
//Though i is integer it will store only integral part i.e., 6
i = a ;
//printf(\"res = %f\", 2 * 6.78); will give the result 13.560000
//But the result is stored in j which is integer
//So integral part of 13.56 is 13. So 13 is stored in j

j = 2 * a;
//i contains 6 so k result is 12
k = 2 * i;
printf(\"i = %d, j = %d , k = %d\", i, j ,k);
}

Output:

i = 6, j = 13 , k = 12

 What will be the output of the following program. int i = 6, j = 7, k = 8; float a = 6.78; i = a; j =2 * a; k = 2 *i; printf (\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site