Monday, 16 July 2018

PROGRAM = 2

#include<stdio.h>

float squrt(int m)
{
    int counter = 0;
    float g1,g2;
    g2=(float)m/2;
    do
    {
        g1=g2;
        g2=(g1+(m/g1))/2;
        counter ++;
    }
    while((g1-g2)>0.01);
    printf("%d",counter);
    return g2;
   
}
void main()
{
int m;
    printf("enter the value");
        scanf("%d",&m);
   
    printf(" Time is counter value  \nsqurt root of  %d is %f \n",m,squrt(m));
    squrt(m);
   
       
}

DAA Program

PROGRAM =1



#include<stdio.h>

float squrt(int m){
    float n;
    int counter=0;
        n=(float)m/2;
        while ((n*n)>m){
            n=n-1;
            counter++;
        }
    while ((n*n)<m){
            n=n+0.1;
        counter++;
        }
    while ((n*n)>m){
            n=n-0.01;
        counter++;
        }
           
    printf("\n %d",counter);

}
void main()
{
int m;
    printf("enter the value");
        scanf("%d",&m);
   
    printf("counter is :- \n squrt root of  %d is %f",m,squrt(m));
   
       
}