Skip to main content

Posts

Showing posts from April 13, 2021

How to check if the given number is Even or odd-

1. How to check if the given number is Even or odd- We can determine whether a number is even or odd. This can be tested using different methods. The test can be done using simple methods such as testing the number’s divisibility by 2. If the remainder is zero, the number is even. If the remainder is not zero, then the number is odd. The following algorithm describes how a C program can test if a number is even or odd. CODE:- #include <stdio.h> int   main () { int num;//variable declaration printf("Enter any num: ");// take input from user  scanf("%d",&num);// declare input if(num%2==0) { printf("The num %d is even",num); } else { printf("The num %d is odd",num); } return 0; }     ALGORITHM:- Step 1.   Start Step 2 .   Enter a number. Step 3.   If the number is divisible by 2, it is even. Step 4 .   If the number is not divisible by 2, it is odd. Step 5.  Stop EXAMP