Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

If Else Practice(Next Odd or Even number)

Wednesday, May 18, 2011

#include <iostream.h>
#include <conio.h>
int main ()
{
    clrscr();
    int n;
    cout <<"Enter Your Number : ";
    cin >> n;
    cout <<endl;
    if (n%2==0)
    {
        n++;   //n=n+1
        cout << n <<" Is Next Odd Number " <<endl;
    }
    else
    {
        n++;   //n=n+1
        cout << n <<" Is Next Even Number " <<endl;
    }
    getch();
    return 0;
}