Checking if a number is odd or even

Program to check given number is even number or not


// Write a program to check given number is even number or not
// Ex: 4 -> Even, -3 -> Not Even
#include
int main(){
    int n,i;
    printf("Enter a integer:"); // input from user
    scanf("%d",&n);
    if(n%2==0){ // checking if even or not
         printf("%d is a even number",n);      
    }
    else{
         printf("%d is not even number",n);
    }
    getch();
}

No comments:

Post a Comment