Wednesday, October 3, 2018

CPL 12 - SQUARE ROOT OF A NUMBER

12. Develop a program to find the square root of a given number N and execute for all possible inputs with appropriate messages. Note: Don’t use library function sqrt(n).

Algorithm:

Step 1: start

Step 2: read number

Step 3: calculate number to the power of 0.5(sq=pow(n,0.5))

Step 4: print sq


Step 5: stop

FLOWCHART:


PROGRAM:

#include<stdio.h>
#include<math.h>

int main()
{
  float n,result;
  printf("enter the value of n\n");
  scanf("%f",&n);
  result=pow(n,0.5);
  printf("square root of %f is %f\n",n,result);

}

OUTPUT:

No comments:

Post a Comment