#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();
}
#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