0

tell me the output of the following program with explanation...Thnx

#include<iostream.h> #include<conio.h> void main() { float c; int a=10,b=3; c=(float)(a/b) cout《c; getch(); }

11th Jul 2016, 11:52 AM
Ishan saini
Ishan saini - avatar
4 Answers
+ 1
OUTPUT: 3 EXPLANATION: You are first dividing both integers and then typecasting the result to float. integer/integer gives integer as result. SOLUTION: c= (float) ( (float)a/ (float)b ); or c= (float)a/ (float)b;
11th Jul 2016, 2:10 PM
Suraj Bobade
Suraj Bobade - avatar
0
The output is 3 because c is 3.0f at the end. That's because you cast (a/b) to float, but a and b are ints so the result of a/b has to be an int, wich then you cast it to a float. So, a/b = 3 and float(a/b) = 3.0f
11th Jul 2016, 1:59 PM
Garme Kain
Garme Kain - avatar
0
3
11th Jul 2016, 2:00 PM
Nikhil
Nikhil - avatar
- 1
3.33
11th Jul 2016, 12:03 PM
Priyank Bhardwaj
Priyank Bhardwaj - avatar