8th Simple C++ Program - Tutorial

ssendi By ssendi, 13th Apr 2012 | Follow this author | RSS Feed | Short URL http://nut.bz/25hbjeze/
Posted in Wikinut>Guides>Technology>Computer Software

This program writtes all odd numbers between numbers that user types...It is similar to "7th Simple C++ Program", but only difference is that this program shows odd numbers on the screen...

8th Simple C++ Program - Tutorial

/*
This program writtes all odd numbers between numbers that user types...It is similar to "7th Simple C++ Program", but only difference is that this program shows odd numbers on the screen...
for even numbers -->> i%2==0
for odd numbers -->> i%2!=0
in "if" loop
*/

#include <iostream>
using namespace std;
int main()
{
int option=1;
while(option!=0){
int number1;
int number2;
cout<<"Please enter 2 numbers: "<<endl;
cin>>number1;
cin>>number2;
cout<<"All odd numbers between these two numbers are: ";
for(int i=number1+1;i<number2;i++){
if(i%2!=0){
cout<<i<<", ";
}}
cout<<endl<<endl;
cout<<"To exit type 0 , if you want to try again type any other number:";
cin>>option;
cout<<endl<<endl;
}
cout<<endl<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}


Here you can find more C++ Programs.....

moderator Steve Kinsman moderated this page.
If you have any complaints about this content, please let us know

Comments

author avatar Denise O
29th Jun 2012 (#)

Thank you for sharing.:)

Reply to this comment

Add a comment
Username
Can't login?
Password