Math and Number Utilities in C

Practice sums, factorials, Fibonacci, divisors, GCD/LCM, powers, primes, palindrome checks, and Armstrong numbers. Emphasis on efficient loops and numeric utilities.

C Program to Find Factorial of a Number

Program (C)
Example & Output

Iterative factorial.

Factorial = 120

C Program to Calculate the Sum of Natural Numbers

Program (C)
Example & Output

Sum 1..n.

Sum = 5050

C Program to Generate Multiplication Table

Program (C)
Example & Output

Table of a number.

5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50

C Program to Display Fibonacci Sequence

Program (C)
Example & Output

Generates first N numbers.

0 1 1 2 3 5 8 13 21 34

C Program to Find GCD of two Numbers

Program (C)
Example & Output

Euclidean algorithm.

GCD = 6

C Program to Find LCM of two Numbers

Program (C)
Example & Output

LCM via GCD.

LCM = 36

C Program to Count Number of Digits in an Integer

Program (C)
Example & Output

Counts decimal digits.

Digits = 5

C Program to Reverse a Number

Program (C)
Example & Output

Reverses digits.

Reverse = 4321

C Program to Calculate the Power of a Number

Program (C)
Example & Output

Computes base^exp.

Power = 1024

C Program to Check Whether a Number is Palindrome or Not

Program (C)
Example & Output

Checks if reversed equals original.

121 is palindrome

C Program to Check Whether a Number is Prime or Not

Program (C)
Example & Output

Trial division up to sqrt.

29 is prime

C Program to Display Prime Numbers Between Two Intervals

Program (C)
Example & Output

Lists primes in a range.

11 13 17 19 23 29 31 37 41 43 47

C Program to Check Armstrong Number

Program (C)
Example & Output

Sum of powered digits equals number.

153 is Armstrong

C Program to Display Armstrong Number Between Two Intervals

Program (C)
Example & Output

Lists Armstrong numbers.

153 370 371 407

C Program to Display Factors of a Number

Program (C)
Example & Output

Lists divisors.

1 2 4 7 14 28

C Program to Display Prime Numbers Between Intervals Using Function

Program (C)
Example & Output

Uses helper function.

11 13 17 19 23 29

C Program to Check Prime or Armstrong Number Using User-defined Function

Program (C)
Example & Output

Checks prime or Armstrong.

153 is Armstrong

C Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers

Program (C)
Example & Output

Finds prime pair for N.

34 = 3 + 31

C Program to Find the Sum of Natural Numbers using Recursion

Program (C)
Example & Output

Recursive sum.

Sum = 55

C Program to Find Factorial of a Number Using Recursion

Program (C)
Example & Output

Recursive factorial.

Factorial = 720

C Program to Find G.C.D Using Recursion

Program (C)
Example & Output

Recursive gcd.

GCD = 6

C program to calculate the power using recursion

Program (C)
Example & Output

Recursive exponent.

Power = 1024

Frequently Asked Questions

Use a standard C compiler such as gcc or clang. For example: gcc program.c -o program && ./program. On Windows, you may use MinGW or tdm-gcc; on macOS/Linux, the default package managers provide compilers.

The programs are compatible with the C99 standard and above. If you use older compilers, ensure the appropriate flags are set or update your toolchain.

Yes. These examples are intended for learning. Copy the code, experiment with changes (e.g., different inputs), and observe the output to deepen understanding.

The examples use standard library functions and portable constructs, and have been tested on major platforms (Windows, macOS, Linux). They should compile and run with any standards-compliant C compiler.

Learn C the Practical Way

C remains one of the most influential programming languages, powering operating systems, embedded devices, and performance-critical software. Practicing small, focused programs builds muscle memory and clarity with syntax and concepts such as data types, control flow, functions, arrays, pointers, and memory management.

On this page, you will find clean, well-formatted examples that compile across platforms. Each example includes a short description and expected output so you can quickly verify your understanding. Explore the topics via the sidebar and extend the code to experiment further.

Whether you’re preparing for interviews, working through coursework, or refreshing fundamentals, these examples offer a practical path to mastering C. Bookmark the page and return often to continue improving.