C++ adding int and float variables

Categories:
less than a minute
In this example, we show how to find the sum of 2 variables of type int and float.
#include <iostream>
int main() {
int firstNumber = 11;
float secondNumber = 12.8;
float sum = firstNumber + secondNumber;
std::cout << "Sum: " << sum << std::endl;
return 0;
}
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.