Write a program to check if a number is divisible by 2 or not.

// program to check if a number is divisible by 2 or not.

#include<stdio.h>

#include<math.h>


int main()


{

int x;

printf("enter a number");

scanf("%d", &x);

printf("%d\n", x%2==0);

// if the number is divisible by 2 then the output will be 1(true)

// if the number is not divisible by 2 then the output will be 0(false)

return 0;

}

Comments

Popular posts from this blog

Write a program to check if a number is prime or not.

write a program (keep taking numbers as input from user until user enters an Odd number)

write a program to print all the odd numbers from 1 to 100.