Sunday, 16 October 2016

HHW Q21. WAP to print all square of all nos. in a range entered by user .

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e;
cout<<"Enter the range below "<<"\n";
cout<<" from -- ";
cin>>a;
cout<<" to -- ";
cin>>b;
for (int i=a;i<=b;i++)
{ c=i*i;
  cout<<i<<"^2 = "<<c<<"\n";
}
getch();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...