Sunday, 16 October 2016

HHW Q33B. WAP to print series 1,4,27........

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a=1,b,n;
cout<<"Enter the no. of terms ";
cin>>n;
for(int i=1;i<=n;i++)
{ if (a%2==0)
     { b=a*a;
       cout<<b<<"\n";
       a=a+1;
     }
  else
     { b=a*a*a;
       cout<<b<<"\n";
       a=a+1;
     }
}
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...