518 views
0 votes
0 votes
K is int type

K=2.0/9;

What k will print? In let us c they give that k final value is 0.0

But I think it's value is 0

1 Answer

0 votes
0 votes
  1. An operation between an integer and float always yields a float result. In this operation the integer is first promoted to a float and then the operation is performed. the net result is a float.
    int/int=int 
    float/int=float
    int/float=float
    float/float=float   so the given ans 0.0 will be correct

Related questions

0 votes
0 votes
0 answers
1
garvit_vijai asked Sep 2, 2018
703 views
Please explain the output for the following program: #include<stdio.h>int main() { int i = 100; int *a = &i; float *f = (float *)a; (*f)++; pri...
1 votes
1 votes
1 answer
2
Jaspreet Kaur Bains asked Jan 27, 2018
358 views
what is the meaning of k= (char *) (i*j)it will return k =(char *) (300)
3 votes
3 votes
2 answers
3
0 votes
0 votes
1 answer
4
Sourabh Kumar asked May 13, 2016
969 views