Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Show square roots of 1 to 99

#include <iostream>  #include <cmath>  using namespace std;    int main()  {    int num;    double sq_root;      for(num=1; num < 100; num++) {      sq_root = sqrt((double) num);      cout << num << " " << sq_root << '\n';    }      return 0;  } 1 1 2 1.41421 3 1.73205 4 2 5 2.23607 6 2.44949 7 2.64575 8 2.82843 9 3 10 3.16228 11 3.31662 12 3.4641 13 3.60555 14 3.74166 15 3.87298 16 4 17 4.12311 18 4.24264 19 4.3589 20 4.47214 21 4.58258 22 4.69042 23 4.79583 24 4.89898 25 5 26 5.09902 27 5.19615 28 5.2915 29 5.38516 30 5.47723 31 5.56776 32 5.65685 33 5.74456 34 5.83095 35 5.91608 36 6 37 6.08276 38 6.16441 39 6.245 40 6.32456 41 6.40312 42 6.48074 43 6.55744 44 6.63325 45 6.7082 46 6.78233 47 6.85565 48 6.9282 49 7 50 7.07107 51 7.14143 52 7.2111 53 7.28011 54 7.34847 55 7.4162 56 7.48331 57 7.54983 58 7.61577 59 7.68115 60 7.74597 61 7.81025 62 7.87401 63 7.93725 64 8 65 8.06226 66 8.12404 67 8.18535 68 8.24621 69 8.30662 70 8.3666 71 8.42615 72 8.48528 73 8.544 74 8.60233 75 8.66025 76 8.7178 77 8.77496 78 8.83176 79 8.88819 80 8.94427 81 9 82 9.05539 83 9.11043 84 9.16515 85 9.21954 86 9.27362 87 9.32738 88 9.38083 89 9.43398 90 9.48683 91 9.53939 92 9.59166 93 9.64365 94 9.69536 95 9.74679 96 9.79796 97 9.84886 98 9.89949 99 9.94987