#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main ()
{
int t, sum, n;
double v;
t = 0;
sum = 20;
n = 4 ;
cout << left << fixed << setprecision(2);
cout << setw(10) << " t " << setw(10) << " v " << endl;
cout << setw(10) << sum << endl;
v = 331 * (sqrt((double)1 + sum/273)) ;
while (n <= 40)
{
sum = 20 + t;
t = t + 2;
n = n + 4 ;
v = 331 * (sqrt((double)1 + sum/273)) ;
cout << setw(10) << sum << setw(10) << v << endl;
}
int t, sum, n; t is an integer. So is sum. So is 273
Hence either t/273 or sum/273 will carry out an integer divide. You need a floating-point divide, so put sum/273.0 where 273.0 is of type double and the division will be done properly, giving a result of type double.