Math and Number Utilities in C

Key takeaway: Practice C programming with 71+ runnable code examples covering I/O, loops, arrays, pointers, strings, recursion, and data structures — all with expected output to verify your understanding.

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

Last updated: August 2026

Try Online C Compiler

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 Calculate the Sum of Natural Numbers

Program (C)
Example & Output

Sum 1..n.

Sum = 5050

C Program to Find Factorial of a Number

Program (C)
Example & Output

Iterative factorial.

Factorial = 120

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 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 gcc or clang. Run: gcc program.c -o program && ./program. On Windows use MinGW; on macOS/Linux, compilers are available via package managers. Or use our free online C compiler to run code directly in your browser.

C99 and above. The programs are compatible with C99 standard and newer. If you use older compilers, set -std=c99 flag or update your toolchain.

Yes, absolutely. These examples are intended for learning. Copy the code, experiment with changes (different inputs, edge cases), 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. According to the TIOBE Index, C consistently ranks in the top 2 languages worldwide.

How to Use These Examples

  1. Browse topics in the sidebar and pick an example
  2. Read the description and study the code
  3. Copy the code and compile: gcc program.c -o program \&\& ./program
  4. Compare your output with the expected output shown
  5. Modify inputs or logic to experiment further

Topics Covered

  • Basic I/O, data types, and operators
  • Control flow: if/else, loops, switch
  • Functions, recursion, and modular design
  • Arrays, strings, and matrix operations
  • Pointers, dynamic memory, and file I/O
  • Structures, enums, and sorting algorithms

C Compiler Comparison

CompilerPlatformBest For
GCCLinux, macOS, Windows (MinGW)General use, standards compliance
ClangmacOS, Linux, WindowsFast compilation, clear errors
MSVCWindowsVisual Studio, Windows APIs
OnlineAny (browser)Quick testing, no install

Related:C Tutorial | Online C Compiler | C++ Examples

C Programming & Your Career — Everything You Need to Know

Can I Get a Job Learning C Programming?

Short answer: Yes. C programmers are in demand across embedded systems, operating systems, IoT, automotive software, game engines, and systems programming. Companies like Intel, Qualcomm, NVIDIA, Samsung, Texas Instruments, and ISRO actively hire C developers. According to the TIOBE Index 2024, C consistently ranks in the top 2 most-used programming languages globally.

Entry-level C programming roles typically pay ₹4–8 LPA in India and $60,000–$90,000 in the US. With 3–5 years of experience in embedded C or systems programming, salaries jump to ₹15–30 LPA (India) or $100,000–$150,000 (US). The demand is especially strong in hardware companies and semiconductor firms.

What Jobs Use C Programming Language?

Direct answer: C is used in roles where performance, hardware interaction, and memory control matter. Here are the key job categories:

  • Embedded Systems Engineer: Writing firmware for microcontrollers (STM32, Arduino, ESP32) — automotive, medical devices, IoT
  • Systems Programmer: Building OS kernels, device drivers, compilers — Linux kernel is 100% C
  • Game Engine Developer: Low-level engine code for performance-critical rendering (Unreal Engine uses C/C++)
  • Network/Security Engineer: Writing firewalls, packet analyzers, VPN software, cryptographic libraries
  • Aerospace/Defense: Flight control systems, satellite software, missile guidance — ISRO, DRDO, NASA all use C
  • Database Internals: MySQL, PostgreSQL, Redis, SQLite — all written in C
  • Compiler/Toolchain Developer: GCC, LLVM, interpreters for other languages

Should I Learn C or Python for My First Programming Language?

It depends on your career goal. If you want to understand how computers actually work — memory, pointers, CPU architecture — start with C. If you want to build applications quickly (web, data science, automation) — start with Python. Here's the honest comparison:

CriteriaCPython
Learning difficultyHard (manual memory, pointers)Easy (readable, forgiving)
Time to first program1–2 weeks1–2 days
Job marketEmbedded, systems, hardwareWeb, AI/ML, data science
Understanding of CS fundamentalsDeep (memory, OS, hardware)Surface-level
Switching to other languages laterEasy (C → anything)Moderate (Python → C is hard)
Best forCS students, hardware rolesBeginners, data/web roles

Our recommendation: If you're a CS/ECE student — learn C first, then Python. If you're a self-taught developer wanting web jobs — learn Python/JavaScript first, then C later if needed.

Should I Learn C Before Python or After?

Before, if possible. Learning C first gives you a deep understanding of how variables are stored in memory, how functions use the call stack, and why certain operations are expensive. When you then switch to Python, you'll understand what Python hides from you (garbage collection, dynamic typing, reference counting) — making you a significantly better programmer.

However, if C's difficulty discourages you from programming entirely, start with Python to build confidence, then come back to C within 6 months. The worst outcome is giving up programming because C felt too frustrating.

The Four Types of C Programming Explained

Direct answer: C programming is used in four major domains, each with different skills and tools:

  1. Systems Programming: Writing operating systems, kernels, device drivers. Tools: GCC, GDB, Makefiles. Example: Linux kernel development.
  2. Embedded Programming: Writing firmware for microcontrollers and hardware. Tools: Keil, IAR, PlatformIO. Example: STM32 sensor boards, Arduino projects.
  3. Application Programming: Building desktop software, databases, and utilities. Tools: Standard C libraries, POSIX APIs. Example: Redis, Git (written in C).
  4. Competitive/Algorithmic Programming: Solving DSA problems in C for speed and low memory. Tools: Online judges (Codeforces, LeetCode). Example: ICPC, Google Code Jam.

Do I Need Years of Experience for C Programming Jobs?

Not necessarily. Entry-level embedded C roles and fresh-graduate systems programming positions exist at companies like TCS, Infosys, Wipro, Continental, Bosch, and semiconductor startups. What matters more than years is demonstrable skill:

  • A GitHub portfolio with C projects (even simple ones like a custom shell, memory allocator, or linked list library)
  • Understanding of pointers, memory management, and data structures implemented from scratch
  • Familiarity with hardware concepts (registers, interrupts, GPIO) for embedded roles
  • Competitive programming ratings on platforms like Codeforces or HackerRank

Why Should I Learn C Programming?

Five reasons C is worth learning in 2026:

  1. Foundation for everything: Python, Java, Go, Rust — all built on concepts from C. Understanding C makes every other language easier.
  2. Performance: C is 10–100× faster than Python for compute-intensive tasks. When speed matters (real-time systems, games, HFT), C is the answer.
  3. Hardware access: C is the only widely-used language that lets you directly manipulate memory addresses, registers, and hardware.
  4. Longevity: C has been relevant for 50+ years and will remain so because operating systems, databases, and embedded devices aren't going away.
  5. Interview advantage: Companies like Google, Amazon, and Apple ask pointer/memory questions in interviews — C knowledge gives you an edge even for non-C roles.

What Certifications Help With C Programming Jobs?

Relevant certifications:

  • CLA (C Programming Language Certified Associate) by C++ Institute — internationally recognized, validates C fundamentals
  • CLP (C Certified Professional Programmer) — advanced certification for experienced C developers
  • Embedded C certifications by Udemy/Coursera — less formal but good for resume (e.g., "Mastering Microcontroller with Embedded C")
  • NPTEL C Programming certificate — free from IITs, recognized by Indian companies
  • Linux Foundation certifications — LFCS (Linux Foundation Certified SysAdmin) involves C/systems knowledge

That said, certifications are secondary to projects and practical skills. A GitHub repo with a working TCP server written in C impresses interviewers more than any certificate.

C Programming vs Other Languages: Which Should You Learn?

LanguageBest ForSpeedLearning CurveJob Market
CSystems, embedded, hardwareFastestHardNiche but high-paying
C++Games, HFT, competitive progVery fastVery hardLarge (finance, gaming)
PythonAI/ML, web, scriptingSlowEasyLargest overall
RustSafe systems programmingFast (≈C)HardGrowing rapidly
GoBackend, DevOps, cloudFastEasyStrong (infra companies)
JavaEnterprise, AndroidModerateModerateVery large (enterprise)

Is Learning C Worth It in 2026?

Absolutely yes. Despite being 50+ years old, C remains irreplaceable for:

  • The entire Linux kernel (30+ million lines of C code, maintained by thousands of developers)
  • Every operating system (Windows kernel, macOS kernel, Android's HAL layer)
  • IoT devices — 75 billion connected devices by 2025 (per Statista), most running C firmware
  • Electric vehicles — Tesla, Rivian, and traditional automakers use C for safety-critical ECU software
  • New languages like Rust and Zig are designed to be "better C" — meaning C's problem domain is alive and expanding

C is not going anywhere. It's the assembly language of the 21st century — you don't write it for everything, but understanding it makes you a fundamentally better engineer.

Sources: TIOBE Index 2024, StackOverflow Developer Survey 2024, Statista IoT Report, LinkedIn Job Postings Data. Practice C with the examples above — each one runs directly in your browser via our online C compiler.