Check Whether A Number Is Even Or Odd | User Given Number | C-Program

Even or Odd:

Tips:

1.Consider a variable 
2.Use if and else
3.Use "%" operator for remainder.
4.Then execute.

Code:

#include<stdio.h>

void main()

{
    int a;

    printf("Enter a number to check even or odd:\n");

    scanf("%d",&a);

    if(a%2==0)

        printf("Even!");

    else

        printf("Odd!");

    getch();

}

 

Output:

 


Comments

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Find Factorial using Recursion | C Program: