0
wt is output if a=2.0,b=2.5 #include <iostream> using namespace std; int main() { int a, b; int sum; cout << "Enter a number \n"; cin >> a; cout << "Enter another number \n"; cin >> b; sum = a + b; cout << "Sum is: " << sum << endl; return 0; }
21 Answers
+ 4
answer would be 4
it is bcoz since u hav taken a and b as int.. so the compiler takes in value of b as 2 rather than 2.5...
and also value of a as just 2 instead of 2.0..
so in short u have declared int variables so it would not accept float types.
so answer is 4..😊
+ 3
Declare it as float for accuracy
+ 2
4 since uhave declared it as int
+ 2
4 as in variable declaration it has been declared as int
+ 2
4 as the declared data type are of integer type
+ 2
The answer is 4 since u have declared it as an integer, if it was float then it wud have been 4.5
+ 2
Integars are whole numbers. Any and all numbers to the right of a decimal are dropped for the Integar data type. Declare it as a float to allow for decimals.
+ 1
4
+ 1
4
+ 1
4
+ 1
ans is:4, as variables have data type as int in declaration
+ 1
4 because you declared sum as integer. if you want the real, mathematical result, change all variables type as double
+ 1
answer is 4 because you have declared b as int so it takes only integer value if you have given double or float for b it will display the answer as 4.5
+ 1
4 is ur answer,
and
if u use 'float' instead of 'int' then ur ans will be 4.5.
+ 1
the output will be "Sum is 4
+ 1
to want accurate answer use float instead of int so the compiler will consider value of b as 2.5 otherwise in int it will consider 2.
+ 1
4
+ 1
the output would be 4 as the compiler takes 2.0 as 2 in case of integer type variable declaration and 2.5 would be taken as 2 because u know int type variable. so simply the compiler would sum like
2+2 and ur answer would be 4
+ 1
Sum is 4.5
+ 1
4