You are here:   HomeC Programming (Theory)Control Structures in CWrite a C program to for loop without the third part.

# Write a C program to double calculation: square

by Dinesh Thakur Category: Control Structures

```#include <stdio.h>

#include<conio.h>

#include <math.h>

void main()

{

double i;

clrscr();

for(i = 1.0; i <=5.0; i+-t+)

{

printf("square root of %If = %If\n", i, sqrt(i»;

printf("Whole number part = %d ", (int)sqrt(i»;

printf("Fractional part = %lf\n", sqrt( i ) - (int) sqrt(i));

printf("\n");

}

getch();

}

OUTPUT:

square root of 1.000000=1.000000

Whole number part =1 Fractional part =0.000000

square root of 2.000000=1.414214

Whole number part =1 Fractional part =0.414214

square root of 3.000000=1.732051

Whole number part =1 Fractional part =0.732051

square root of 4.000000 =2.000000

Whole number part =2 Fractional part =0.000000

square root of 5.000000 =2.236068

Whole number part =2 Fractional part =0.236068
```

 Name E-mail

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.

What's New and Popular

Popular Article

Search Content

Basic Courses