C++ Program For Printing Odd Numbers with Their Multiples

Program Code:

#include<iostream.h>
#include<conio.h>#include<iomanip.h>
void main(){int i,j,n;
cout<<"Enter the limit : ";cin>>n;
if(n%2 == 0 )n=n-1;
cout<<endl<<setw(4)<<"Multiples of the odd numbers upto "<<n;for(i=n;i>0;i-=2){cout<<endl<<i<< ":";for(j=1;j<=i;++j)if(i%j == 0)cout<<setw(4)<<j;}getch();}


Output:

.exe file

No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.