Square in ordered Pairs

22:38 0 Comments A+ a-

Problem:
Write a program that should take two numbers (that is, first and last) from user and display all the numbers and their squares in the form of an ordered pair between first and last numbers.
Sample Run 1:
Enter first: 2
Enter last: 5
(2,4) (3,9) (4,16) (5,25)
Solution Code:
# include <iostream>
# include <cmath>
using namespace std;
int main()
{
int first,last,diff;
cout<<"Enter First No : ";
cin>>first;
cout<<"Enter Second No : ";
cin>>last;
while(first>last)
{
cout<<"Invalid range as "<<first<<" is not less than equal to "<<last<<endl;
cout<<"Enter First No again : ";
cin>>first;
cout<<"Enter Second No again : ";
cin>>last;
}
while(first<=last)
{
cout<<"("<<first<<","<<pow(first,2)<<")\t";
first++;
}
cout<<endl;





system("pause");

}