using C write a program that asks the user to type a positiv
using C++ write a program that asks the user to type a positive number and displays the square root of the number. If the user writes a negative number, the program writes, ERROR and they must type another value.
Solution
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int num,a ; //declare variables
clrscr();
cout<<\"Enter any Number: \"; //enter number
cin>>num;
if(num>0)//check the condition enter number is positiv eor negetive
{
a =sqrt(num);;
cout<<\"\ Squre of \"<<num<<\" is: \"<<a ;
}
else
cout<<\"ERROR,Must type anothre value\";
getch();
}
out put:enter any number
