Print square roots from 1 to 9 - C Program

C program to print the square roots from 1 to 9.

Solution:


#include<stdio.h>
#include<math.h>
int main()
{
      int i=1;
      float square_roots;
      /* Calculating and printing square-roots of number 1 to 9*/
      printf("Square roots of numbers from 1 to 9 are:\n\n");
      for(i=1;i<=9;i++)
      {
            square_roots=sqrt(i);
            printf("\t%d = %.2f\n",i,square_roots);
      }
      return 0;
}


Output:

number and square roots