Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

PROGRAM TO CHECK GIVEN NUMBER IS ODD OR EVEN

Posted By: Jasmina Akhtar     Category: C Programming     Views: 14906

PROGRAM TO CHECK GIVEN NUMBER IS ODD OR EVEN

Code for PROGRAM TO CHECK GIVEN NUMBER IS ODD OR EVEN in C Programming

#include<stdio.h>
#include<conio.h>

void main()
{
    int n,ch;
    clrscr();

    printf("Enter the number:-");
    scanf("%d",&n);

    printf("\n1. Without Using Else Option\n");
    printf("\n2. With Using Else Option\n");

    printf("\nEnter your choice :: ");
    scanf("%d",&ch);

    if(ch == 1)
    {
        if(n % 2 == 0)
        printf("\nEntered number is even \n ");
        if(n % 2 != 0)
        printf("\nEntered number is odd \n ");
    }

    if(ch == 2)
    {
        if(n % 2 == 0)
        printf("\nEntered number is even \n ");
        else
        printf("\nEntered number is odd \n ");
    }
    getch();
}

/*
********
OUTPUT
********
Enter the number:-12

1. Without Using Else Option

2. With Using Else Option

Enter your choice :: 1

Entered number is even


Enter the number:-13

1. Without Using Else Option

2. With Using Else Option

Enter your choice :: 2

Entered number is odd

*/
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM TO CHECK GIVEN NUMBER IS ODD OR EVEN Or get search suggestion and latest updates.

Jasmina Akhtar
Jasmina Akhtar author of PROGRAM TO CHECK GIVEN NUMBER IS ODD OR EVEN is from Karachi, Pakistan.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!