Basic C Programs Every Student Should Practice Before Semester Exams

Basic C Programs Every Student Should Practice Before Semester Exams
If you're preparing for a programming exam, one of the smartest strategies is to practice the most common C programs that universities frequently ask in practical tests.
These programs usually focus on basic logic like loops, conditions, arrays, and functions. Once you understand these concepts clearly, many other programming questions become easier to solve.
Below are some essential C programs that almost every computer science student should practice before semester exams.
1. Program to Print Numbers from 1 to 10
#include <stdio.h>
int main() {
int i;
for(i = 1; i <= 10; i++) {
printf("%d ", i);
}
return 0;
}
2. Program to Find Sum of First N Natural Numbers
#include <stdio.h>
int main() {
int i, n = 5, sum = 0;
for(i = 1; i <= n; i++) {
sum = sum + i;
}
printf("Sum = %d", sum);
return 0;
}
3. Program to Reverse a Number
#include <stdio.h>
int main() {
int num = 123, rev = 0, rem;
while(num != 0) {
rem = num % 10;
rev = rev 10 + rem;
num = num / 10;
}
printf("Reversed Number = %d", rev);
return 0;
}
4. Program to Check Palindrome Number
#include <stdio.h>
int main() {
int num = 121, temp, rev = 0, rem;
temp = num;
while(num != 0) {
rem = num % 10;
rev = rev 10 + rem;
num = num / 10;
}
if(temp == rev)
printf("Palindrome Number");
else
printf("Not Palindrome");
return 0;
}
5. Program to Print Fibonacci Series
#include <stdio.h>
int main() {
int n = 10, a = 0, b = 1, c, i;
printf("%d %d ", a, b);
for(i = 2; i < n; i++) {
c = a + b;
printf("%d ", c);
a = b;
b = c;
}
return 0;
}
Other Important Programs Students Should Practice
- Program to find largest number in an array
- Program to search an element in an array
- Program to sort numbers using bubble sort
- Program to count vowels in a string
- Program using functions in C
- Program using pointers
- Program using structures
- Program for matrix addition
- Program for file handling
Students who regularly practice these programs usually find it much easier to handle both theoretical questions and practical coding tasks during semester exams.

Written by
Palak PatelEducation writer Palak Patel covers the latest education news, board exam updates, results, and career opportunities.
Comments
No comments yet. Be the first!
