Find the Transpose of a 2-D Matrix in C

This program finds the transpose of a given 2-D matrix (rows become columns and columns become rows). C Program #include <stdio.h> int main() { int a[10][10], transpose[10][10]; int m, n, i, j; printf(“Enter number of rows (m) and columns (n): “); scanf(“%d %d”, &m, &n); printf(“Enter elements of the matrix:\n”); for (i = 0; i … Read more

Menu-Driven Unit Converter Using Switch Statement in C

This program implements a menu-driven unit converter (kilometers to miles, Celsius to Fahrenheit) using a switch statement. C Program #include <stdio.h> int main() { int choice; float value, result; printf(“Unit Converter Menu\n”); printf(“1. Kilometers to Miles\n”); printf(“2. Celsius to Fahrenheit\n”); printf(“Enter your choice: “); scanf(“%d”, &choice); switch (choice) { case 1: printf(“Enter distance in kilometers: … Read more

Check Whether a Character Is a Vowel, Consonant, Digit, or Special Character in C

This program reads a character from the keyboard and, using if-else statements, determines whether it is a vowel, consonant, digit, or special character. C Program #include <stdio.h> int main() { char ch; printf(“Enter a character: “); scanf(” %c”, &ch); if ((ch >= ‘a’ && ch = ‘A’ && ch = ‘A’ && ch = ‘0’ … Read more

Implicit and Explicit Type Conversion by Dividing Two Integers in C

This program demonstrates implicit and explicit type conversion by dividing two integers to obtain a floating-point result. C Program #include <stdio.h> int main() { int a, b; printf(“Enter two integers: “); scanf(“%d %d”, &a, &b); int implicit_result = a / b; float explicit_result = (float) a / (float) b; printf(“Integer division (implicit truncation): %d\n”, implicit_result); … Read more

Sort an Array in Ascending Order Using Bubble Sort in C

This program sorts the elements of a 1-D array in ascending order using the bubble sort technique. C Program #include <stdio.h> int main() { int arr[100], n, i, j, temp; printf(“Enter number of elements: “); scanf(“%d”, &n); printf(“Enter %d elements:\n”, n); for (i = 0; i < n; i++) { scanf("%d", &arr[i]); } for (i ... Read more

Display Number of Days in a Month Using Switch Statement in C

This program displays the number of days in a given month (1-12) using a switch statement, taking leap years into account for February. C Program #include <stdio.h> int main() { int month, year, days; printf(“Enter month (1-12): “); scanf(“%d”, &month); printf(“Enter year: “); scanf(“%d”, &year); switch (month) { case 1: case 3: case 5: case … Read more