Write a C++ Program to take a number as an input and print all the numbers in sequence to that number also print odd numbers, even numbers and square of the numbers in arrays separately.
#include<iostream>
using namespace std;
int main()
{
int i,n;
cout<<"Enter the value to which you want to print numbers: ";
cin>>n;
for(i=1;i<=n;i=i+1)
cout<<i<<"\t";
cout<<endl<<"Enter the value to which you want to print even numbers: ";
cin>>n;
for(i=2;i<=n;i=i+1)
{
cout<<i<<endl;
i=i+1;
}
cout<<endl<<"Enter the value to which you want to print Odd numbers: ";
cin>>n;
for(i=1;i<=n;i=i+1)
{
cout<<i<<endl;
i=i+1;
}
cout<<"Enter the value to which you want to print squares: ";
cin>>n;
for(i=1;i<=n;i=i+i)
{
cout<<i<<endl;
}
}
No comments:
Post a Comment