index for c file
index for c file
2 Loop Programs
. Print Numbers from 1 to 100: Write a program to print
2.1
numbers from 1 to 100 using a `for` loop
Sum of First N Natural Numbers: Write a program to
2.2
calculate the sum of the first `N` natural numbers
. Factorial of a Number: Write a program to calculate the
2.3
factorial of a given number `N` using a `for` loop
. Odd Numbers Between 1 and 50: Write a program to
2.4
print all odd numbers between 1 and 50.
Reverse a Number: Write a program to reverse a given
2.5
integer number using a `for` loop
Check Prime Number: Write a program to check if a given
2.6
number `N` is prime.
Count Digits in a Number: Write a program to count the
2.7
number of digits in a given number
3 Pattern Programs
Generate a Pattern: Write a program using a `for` loop to
3.1
print a pyramid pattern with `N` rows. Example for `N=3`:
Square Pattern of Stars: Write a program to print a square
3.2
pattern with `N` rows and columns. Example for `N=4`:
. Right-Angled Triangle Pattern of Numbers: Write a
program to print a right-angled triangle with `N` rows
3.3
where each row has the same number as its row number.
Example for `N=4`:
. Inverted Right-Angled Triangle of Numbers: Write a
program to print an inverted right-angled triangle with
3.4
numbers in decreasing order from `N` down to 1. Example
for `N=5`:
Diamond Pattern of Stars: Write a program to print a
3.5 diamond pattern with `N` rows (assuming `N` is odd).
Example for `N=5`:
. Pascal's Triangle Pattern: Write a program to print the
3.6
first `N` rows of Pascal’s Triangle. Example for `N=5`:
4 1D Array Programs
Find Maximum Element: Write a program to find the
4.1
maximum element in a 1D array of integers
Sum of Array Elements: Write a program to calculate the
4.2
sum of all elements in a 1D array.
Reverse an Array: Write a program to reverse the
4.3
elements of a 1D array.
Search for an Element: Write a program to search for an
4.4
element in a 1D array and return its index if found
Find Minimum and Maximum Element: Write a program to
4.5 find both the minimum and maximum elements in a 1D
array.
Sort Array in Ascending Order: Write a program to sort a
4.6
1D array in ascending order.
Remove Duplicates from an Array: Write a program to
4.7
remove duplicate elements from a 1D array.
5 : 2D Array Programs
Transpose of a Matrix: Write a program to find the
5.1
transpose of a 2D matrix.
Matrix Addition: Write a program to add two 2D matrices
5.2
of the same dimensions.
. Matrix Multiplication: Write a program to multiply two 2D
5.3
matrices
. Sum of Diagonal Elements: Write a program to calculate
5.4
the sum of the diagonal elements of a square matrix
6 Functions
A program that uses a function to calculate the factorial of
6.1 a given number. The function should take an integer as
input and return the factorial value.
A program that includes a function to check whether a
6.2 given number is a prime number. The function should
return 1 if the number is prime and 0 otherwise
A program that includes a function to find the greatest
common divisor (GCD) of two numbers using the
6.3
Euclidean algorithm. The function should take two
integers as parameters and return their GCD.
A program that swaps two numbers using a function. The
function should take two integers by reference (using
6.4
pointers) and swap their values. Display the swapped
values in the main function.