C-Program : WAP to Print Odd & Even Numbers - Cipheronics - Codes n' Electronics.

Hot

Post Top Ad

Responsive Ads Here

Saturday, 22 July 2017

C-Program : WAP to Print Odd & Even Numbers

This is a C-Program to print the Positive, Negative of a Odd or Even Number.


#include <stdio.h>

int main()
{
    int x;

    printf("Enter a Number : ");
    scanf("%d",&x);

    //To determine positive numbers
    if ( x > 0 )
    {
        if ( x % 2 == 0 )
        {
            printf("'%d' is a Positive Even Number!\n",x);
        }
        else
        {
            printf("'%d' is a Positive Odd Number!\n",x);
        }
    }

    //To determine negative numbers
    else if ( x < 0)
    {
        if ( x % 2 == 0 )
        {
            printf("'%d' is a Negative Even Number!\n",x);
        }
        else
        {
            printf("'%d' is a Negative Odd Number!\n",x);
        }
    }
    else
    {
        printf("You've Entered 0!\n");
    }
    return 0;
}


Have a problem.? Then Discuss in Forums here 

No comments:

Post a Comment

Post Top Ad

Responsive Ads Here