Mastering the C programming language is all about consistent practice and getting your hands dirty with real coding. This guide is packed with a selection of beginner-friendly C programs, each one featuring clear explanations and sample outputs. Whether you're just starting out and trying to wrap your head around the basics or you're looking to solidify your understanding of core concepts, these examples will be great tools for your learning journey.

If you're after a more structured approach and some expert guidance, signing up for a C Programming Course in Noida could be a game changer. Places like Uncodemy offer in-depth courses that mix theory with practical exercises, giving you a well-rounded grasp of C programming.
#includeint main() { printf("Hello, World!\n"); return 0; }
Hello, World!
This is the classic beginner program that simply prints "Hello, World!" to the console. It's a great way to get familiar with the syntax and structure of a C program.
#includeint main() { int number; printf("Enter an integer: "); scanf("%d", &number); printf("You entered: %d\n", number); return 0; }
Enter an integer: 25
You entered: 25
This program shows you how to capture user input with scanf and then display it using printf.
#includeint main() { int a, b, sum; printf("Enter two integers: "); scanf("%d %d", &a, &b); sum = a + b; printf("Sum: %d\n", sum); return 0; }
Enter two integers: 10 20
Sum: 30
This program adds two integers provided by the user and displays the result.
#includeint main() { float a, b, product; printf("Enter two numbers: "); scanf("%f %f", &a, &b); product = a * b; printf("Product: %.2f\n", product); return 0; }
Enter two numbers: 2.5 4.0
Product: 10.00
This program multiplies two floating-point numbers and displays the product with two decimal places.
#includeint main() { char c; printf("Enter a character: "); scanf("%c", &c); printf("ASCII value of %c = %d\n", c, c); return 0; }
Enter a character: A
ASCII value of A = 65
This program takes a character input from the user and displays its corresponding ASCII value.
#includeint main() { int num; printf("Enter an integer: "); scanf("%d", &num); if (num % 2 == 0) printf("%d is even.\n", num); else printf("%d is odd.\n", num); return 0; }
Enter an integer: 7
7 is odd.
This program determines if the number you input is even or odd by using the modulo operator.
#includeint main() { int a, b, c; printf("Enter three numbers: "); scanf("%d %d %d", &a, &b, &c); if (a >= b && a >= c) printf("Largest number: %d\n", a); else if (b >= a && b >= c) printf("Largest number: %d\n", b); else printf("Largest number: %d\n", c); return 0; }
Enter three numbers: 10 20 15
Largest number: 20
This program takes three numbers and figures out which one is the biggest.
#includeint main() { int year; printf("Enter a year: "); scanf("%d", &year); if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) printf("%d is a leap year.\n", year); else printf("%d is not a leap year.\n", year); return 0; }
Enter a year: 2020
2020 is a leap year.
This program checks whether a given year is a leap year based on the standard rules.
#includeint main() { int n, i; printf("Enter a positive integer: "); scanf("%d", &n); for (i = 1; i <= n; ++i) printf("%d ", i); return 0; } < pre> =>
Enter a positive integer: 5
1 2 3 4 5
This program prints all natural numbers from 1 to the user-specified number using a for loop.
#includeint main() { int n, i, sum = 0; printf("Enter a positive integer: "); scanf("%d", &n); for (i = 1; i <= n; ++i) sum +="i;" printf("sum='%d\n",' sum); return 0; } < pre> =>
Enter a positive integer: 10
Sum = 55
This program calculates the sum of all natural numbers up to the specified number.
#includeint main() { int n, i; printf("Enter an integer: "); scanf("%d", &n); for (i = 1; i <= 10; ++i) printf("%d x %d='%d\n",' n, i, n * i); return 0; } < pre> =>
Enter an integer: 5
5 x 1 = 5
5 x 2 = 10
...
5 x 10 = 50
This program displays the multiplication table of the entered number up to 10.
#includeint main() { int n, i; float arr[100]; printf("Enter the number of elements (1 to 100): "); scanf("%d", &n); for (i = 0; i < n; ++i) { printf("Enter number%d: ", i + 1); scanf("%f", &arr[i]); } for (i = 1; i < n; ++i) { if (arr[0] < arr[i]) arr[0] = arr[i]; } printf("Largest element = %.2f\n", arr[0]); return 0; }
Enter the number of elements (1 to 100): 5
Enter number1: 3.4
Enter number1: 3.4
Enter number2: 2.5
Enter number3: 5.1
Enter number4: 1.2
Enter number5: 4.8
Largest element = 5.10
This program finds the largest element in a user-defined array.
#includeint main() { int num, reversed = 0, remainder; printf("Enter an integer: "); scanf("%d", &num); while (num != 0) { remainder = num % 10; reversed = reversed * 10 + remainder; num /= 10; } printf("Reversed number = %d", reversed); return 0; }
Enter an integer: 1234
Reversed number = 4321
This program uses a while loop to extract digits from the number and reverse their order. A great way to learn about loops and modular arithmetic in C.
#includeint factorial(int n) { if (n == 0) return 1; else return n * factorial(n - 1); } int main() { int num; printf("Enter a number: "); scanf("%d", &num); printf("Factorial of %d = %d", num, factorial(num)); return 0; }
Enter a number: 5
Factorial of 5 = 120
This program defines a recursive function to compute the factorial of a number. It’s a solid example to understand recursion and function usage in C.
Before you hit that compile button, taking a moment to do a dry run of your program is a smart move, especially if you're just starting out. A dry run involves going through your code manually, line by line, and predicting what each variable will hold or what the outcome will be. This practice not only helps you grasp how the logic flows but also clarifies what each statement does and where you might stumble upon a bug.
By dry running your C programs, you’ll also deepen your grasp of how loops work, how conditionals execute, and how memory is allocated. Many common programming pitfalls—like infinite loops, wrong outputs, or segmentation faults—can be sidestepped simply by tracing through your logic beforehand.
As beginners work through these C language programs, they can solidify their understanding of key concepts such as variables, loops, conditionals, arrays, and functions. Mastering these examples is not just vital for nailing technical interviews; it’s also essential for excelling in academic exams and tackling larger projects.
To speed up your learning journey, think about signing up for the C Programming Course in Noida (uncodemy.com). At Uncodemy, you’ll dive into real-world projects, learn from expert mentors, and receive placement assistance—an ideal launchpad for a career in software development.
Q1. Why should beginners practice basic programs in C?
Ans: Getting hands-on with basic programs is a great way for beginners to sharpen their logical thinking skills, grasp the syntax, and become familiar with essential programming concepts like loops, conditionals, and functions.
Q2. How do arrays help in C programming?
Ans: Arrays are super useful because they let you store multiple values in one variable. This makes it much easier to handle lists and carry out tasks like sorting, searching, and manipulating data efficiently.
Q3. What is recursion in C?
Ans: Recursion happens when a function calls itself to tackle a smaller version of the same problem. It's a popular technique for solving issues like calculating factorials, generating Fibonacci series, and traversing trees.
Q4. Which IDE should I use for running C programs?
Ans: For beginners, Turbo C++, Code::Blocks, or Visual Studio Code with a GCC compiler are great options. If you're on Linux, you can run GCC directly from the terminal.
Q5. Is Uncodemy good for learning C programming?
Ans: Absolutely! Uncodemy provides a well-structured C Programming Course in Noida, complete with practical examples, live projects, interview preparation, and placement support—perfect for beginners and job seekers alike.
Q6. Are these practice programs helpful in cracking interviews?
Ans: Definitely! These programs are excellent for testing your understanding of logic and syntax, which are often key topics in interviews for entry-level programming or developer positions.
Personalized learning paths with interactive materials and progress tracking for optimal learning experience.
Explore LMSCreate professional, ATS-optimized resumes tailored for tech roles with intelligent suggestions.
Build ResumeDetailed analysis of how your resume performs in Applicant Tracking Systems with actionable insights.
Check ResumeAI analyzes your code for efficiency, best practices, and bugs with instant feedback.
Try Code ReviewPractice coding in 20+ languages with our cloud-based compiler that works on any device.
Start Coding
TRENDING
BESTSELLER
BESTSELLER
TRENDING
HOT
BESTSELLER
HOT
BESTSELLER
BESTSELLER
HOT
POPULAR