You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
428 B
C++

A Simple for Statement - generate the square root of 1 to 10
#include <iostream>
#include <math.h> // for newer compilers, use <cmath>
using namespace std;
int main()
{
int num;
double sq_root;
for(num=1; num < 10; num++) {
sq_root = sqrt((double) num); //casting num from integer to double
// then taking its square root
cout << num << " " << sq_root << '\n';
}
return 0;
}