write a c++ program to find the square root of 16?
Answers
Answered by
1
Option 1:-
/*
* C program to calculate square root of a number
* using sqrt function
*/
#include <stdio.h>
#include <math.h>
int main () {
double x, result;
printf("Enter a number\n");
scanf("%lf", &x); result = sqrt(x);
printf("Square root of %lf = %lf\n", x, result); return 0;
}
Option 2:-
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int num,ans;
clrscr();
cout<<"Enter any Number: ";
cin>>num;
ans=sqrt(num);;
cout<<"\n Squre of "<<num<<" is: "<<ans;
getch();
}
Output:- Enter a Number: 16
Square root of 16 is: 4
/*
* C program to calculate square root of a number
* using sqrt function
*/
#include <stdio.h>
#include <math.h>
int main () {
double x, result;
printf("Enter a number\n");
scanf("%lf", &x); result = sqrt(x);
printf("Square root of %lf = %lf\n", x, result); return 0;
}
Option 2:-
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int num,ans;
clrscr();
cout<<"Enter any Number: ";
cin>>num;
ans=sqrt(num);;
cout<<"\n Squre of "<<num<<" is: "<<ans;
getch();
}
Output:- Enter a Number: 16
Square root of 16 is: 4
Similar questions