Devise the algorithm for the following and verify whether they satisfy all the features.
1.An algorithm that inputs three numbers and outputs them in ascending order.
2.To test whether the three numbers represent the sides of a right angle triangle.
3.To test whether a given point p (x,y) lies on x-axis or y-axis .
4.To compute the area of a circle of a given circumference
5.To locate a specific word in a dictionary
#include <iostream>
using namespace std;
int main()
{
double n1;
cout<<"\nEnter first number: ";
cin>>n1;
double n2;
cout<<"\nEnter second number: ";
cin>>n2;
double n3;
cout<<"\nEnter third number: ";
cin>>n3;
if (n1<n2 && n3<n2){
if (n1 > n3)
cout<<n3<<" "<<n1<<" "<<n2;
else
cout<<n1<<" "<<n3<<" "<<n2;
}
else if (n1 < n3 && n2 < n3){
if (n1 > n2)
cout<<n2<<" "<<n1<<" "<<n3;
else
cout<<n1<<" "<<n2<<" "<<n3;
}
else if (n2 < n1 && n3 < n1){
if (n3 > n2)
cout<<n2<<" "<<n3<<" "<<n1;
else
cout<<n3<<" "<<n2<<" "<<n1;
}
else
cout<<n1<<" "<<n2<<" "<<n3;
return 0;
}
Comments
Leave a comment