Write a program to check a number is even or odd

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

No comments:

Post a Comment