
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C Program to Check if count of divisors is even or odd?
Given a number “n” as an input, this program is to find the total number of divisors of n is even or odd. An even number is an integer that is exactly divisible by 2. Example: 0, 8, -24
An odd number is an integer that is not exactly divisible by 2. Example: 1, 7, -11, 15
Input: 10 Output: Even
Explanation
Find all the divisors of the n and then check if the total number of divisors are even or odd. To do this find all divisor and count the number and then divide this number by 2 to check if it is even or odd.
Example
#include <iostream> #include <math.h> using namespace std; int main() { int n=10; int count = 0; for (int i = 1; i <= sqrt(n) + 1; i++) { if (n % i == 0) count += (n / i == i) ? 1 : 2; } if (count % 2 == 0) printf("Even
"); else printf("Odd
"); return 0; }
- Related Articles
- Java Program to check if count of divisors is even or odd
- Python Program for Check if the count of divisors is even or odd
- Check if count of divisors is even or odd in Python
- PHP program to check if the total number of divisors of a number is even or odd
- C++ Program to Check Whether Number is Even or Odd
- Java Program to Check Whether a Number is Even or Odd
- C# Program to check if a number is Positive, Negative, Odd, Even, Zero
- How to Check if a Number is Odd or Even using Python?
- 8085 program to check whether the given number is even or odd
- Program to check if a number is Positive, Negative, Odd, Even, Zero?
- Java Menu Driven Program to Check Positive Negative or Odd Even Number
- Program to find count of numbers having odd number of divisors in given range in C++
- C++ program for the Array Index with same count of even or odd numbers on both sides?
- C++ Program to Print “Even” or “Odd” without using conditional statement
- C Program to print “Even” or “Odd” without using Conditional statement

Advertisements