What is the output of the following program lines (when embedded in a correct program that declares number to be of type int)?
number = (1/3) * 3;
cout << "(1/3) * 3 is equal to " << number;
#include <iostream>
using namespace std;
int main()
{
//declares number to be of type int
int number;
//Calculate the value and store result in number
number= (1/3) * 3;
//Print output
cout << "(1/3) * 3 is equal to " << number;
cout<<endl;
system("pause");
return 0;
}
Output:
(1/3) * 3 is equal to 0
Explanation:
Declared the variable name, "number" with the data type is "int(integer)". the variable, number accepts only intger values, not accept decimal values in any case. So, the actuall output of the (1/3) * 3=0.999, but display the result only 0.