Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user