Learn about Odd Number Program in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Odd Number Program in C
Odd numbers are whole numbers that cannot be divided into pairs exactly.
When odd numbers are divided by two, the remainder is 1.
Source code:
#include<stdio.h>
int main()
{
int number;
printf("Enter number: ");
scanf("%d",&number);
if(number%2 != 0)
printf("%d is an Odd number \n", number);
else
printf("%d is not an Odd number \n", number);
return 0;
}
Output:
Enter number: 3
3 is an Odd number
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C program to print even numbers using for loop
Even Number Program in C