Hey all please try these C Programs and get efficiency in learning
1. Multiplication Table Generator:
Create a program that generates multiplication tables for a given number using loops. The user inputs the number, and the program displays the table.
Coding for this
#include <stdio.h> int main() { int num; printf("Enter a number: "); scanf("%d", &num); printf("Multiplication Table for %d:\n", num); for (int i = 1; i <= 10; i++) { printf("%d x %d = %d\n", num, i, num * i); } return 0; }
Try this here
2. Fibonacci Series:
Write a program to generate and display the Fibonacci series using loops. The user can input the number of terms to display.
The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding ones, usually starting from 0 and 1. Here's the C program to generate and display the Fibonacci series using loops:
#include <stdio.h>
int main() {
int n, first = 0, second = 1, next;
printf("Enter the number of terms: ");
scanf("%d", &n);
printf("Fibonacci Series: %d, %d, ", first, second);
for (int i = 3; i <= n; i++) {
next = first + second;
printf("%d, ", next);
first = second;
second = next;
}
return 0;
}
Explanation:
The program prompts the user to enter the number of terms in the Fibonacci series.
first and second are initialized to 0 and 1, which are the first two terms of the Fibonacci series.
The program prints the first two terms as a starting point.
Using a for loop, the program calculates the next terms of the series (next = first + second), updates first and second to the current values, and prints the next value.
The loop continues until the desired number of terms (n) is reached.
3. Pattern Printing - Half Pyramid:
Design a program that prints a half pyramid pattern of asterisks using nested loops. The user specifies the number of rows.
A half pyramid pattern is a pattern of asterisks (*) where each row has one more asterisk than the previous row. Here's the C program to print a half pyramid pattern based on the user-specified number of rows:
#include <stdio.h>
int main() {
int rows;
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
printf("* ");
}
printf("\n");
}
return 0;
}
The program prompts the user to enter the number of rows for the half pyramid.
Using the outer for loop, the program iterates from 1 to the specified number of rows.
Inside the outer loop, the inner for loop iterates from 1 to the current row number (i).
In each iteration of the inner loop, the program prints an asterisk followed by a space.
After printing all asterisks for the current row, the program moves to the next line using printf("\n").

Try below programs and write codes in the comment
4. Pattern Printing - Inverted Half Pyramid:
Similar to the previous project, print an inverted half pyramid pattern of asterisks.
5. Pattern Printing - Full Pyramid:
Build a program that prints a full pyramid pattern of asterisks using nested loops. The user inputs the number of rows.
6. Pattern Printing - Diamond:
Design a program that prints a diamond pattern of asterisks using loops. The user specifies the number of rows or the height of the diamond.
7. Prime Number Checker:
Create a program that takes an input from the user and checks whether it's a prime number or not using loops.
8. Factorial Calculator:
Write a program to calculate the factorial of a given number using loops. The user inputs the number.
9. Even and Odd Number Checker:
Design a program that checks whether a given number is even or odd using loops. The user inputs the number.
10. Sum of Digits:
Build a program that calculates the sum of the digits of a given number using loops. The user inputs the number.
11. Palindrome Checker:
Create a program that checks whether a given number is a palindrome (reads the same backward as forward) using loops.
12. Table of Powers:
Write a program that displays the table of powers of a number using loops. The user inputs the base and the number of terms.
13. Reverse a Number:
Design a program that reverses a given number using loops. For example, inputting 12345 should output 54321.
14. Prime Numbers in a Range:
Create a program that generates and displays all prime numbers within a specified range using loops. The user inputs the range.
15. Counting Digits, Even, and Odd:
Build a program that takes a number from the user and counts the number of digits, even digits, and odd digits using loops.
Comments