Double calculation: square : Double « Data Type « C / ANSI-C






Double calculation: square

Double calculation: square
  
#include <stdio.h>
#include <math.h>

int main(void)
{
  double i;

  for(i = 1.0; i < 101.0; i++) {
    printf("square root of %lf = %lf\n", i, sqrt(i));
    
    printf("Whole number part = %d ", (int)sqrt(i));
    
    printf("Fractional part = %lf\n", sqrt( i ) - (int) sqrt( i ));
    
    printf("\n");
  }

  return 0;
}


           
       








Related examples in the same category

1.A function to output double values in a given widthA function to output double values in a given width
2.Table of reciprocals, squares, cubes, and fourth powersTable of reciprocals, squares, cubes, and fourth powers
3.Calculating the area of a room
4.Calculating volume price of alternative productsCalculating volume price of alternative products
5.Calculating average hourly pay rateCalculating average hourly pay rate
6.Convert double to int