1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include<conio.h>
#include<stdio.h>
main()
{float n,i,j,start,end,size,acc_level,c=0,count=0;
clrscr();
printf("Enter the number");
scanf("%f",&n);
printf("%f",epo(10,1));
start=1;end=n;size=1;
for(i=start;i<=end;i+=size)
{
if(n==(i*i))
{
printf("Square root of the entered number is %f",i);
goto end;
}
}
printf("Enter the accuracy level");
scanf("%f",&acc_level);
for(i=start;i<=end;i+=size)
{
if(i*i<n&&(i+size)*(i+size)>=n)
{
start=i,end=i+size;
size=size/10;printf("%f",i);count++;
}
if(count==acc_level)
break;
}
printf("The square root to the desired level is %f",(start+end)*0.5);
end:
getch();
}
|