// Write a C++ program that prints odd numbers in
// ascending order up to given number.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n;
cout<<"Enter any number : ";
cin>>n;
cout<<"\n\n------------------------------------\n";
cout<<" Odd numbers in Ascending Order \n";
cout<<"------------------------------------\n";
if( n%2 == 0 )
n--;
for( i = 1 ; i <= n ; i = i+2 )
cout<<" "<<i<<endl;
getch();
}
// ascending order up to given number.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n;
cout<<"Enter any number : ";
cin>>n;
cout<<"\n\n------------------------------------\n";
cout<<" Odd numbers in Ascending Order \n";
cout<<"------------------------------------\n";
if( n%2 == 0 )
n--;
for( i = 1 ; i <= n ; i = i+2 )
cout<<" "<<i<<endl;
getch();
}
i want a program to print 1,3,5,7,9,9,7,5,3,1 output
ReplyDelete