C Program to read an English sentence and replace lowercase characters by uppercase and vice-versa.

This program reads a sentence and swaps the case of every letter — uppercase becomes lowercase, lowercase becomes uppercase. Digits, spaces, and punctuation are left unchanged. The <ctype.h> functions isupper(), islower(), toupper(), and tolower() make this clean and portable across all ASCII and extended character sets. The original post used conio.h, void main(), a broken …

C program to check whether a given string is palindrome or not

A palindrome is a word, sentence, or sequence that reads the same forward and backward — ignoring differences in capitalization for word-level palindromes. Examples: “racecar”, “GADAG”, “level”, “9009”. The most efficient check uses a two-pointer approach: one pointer starts at the left end, one at the right, and they advance toward each other until they …

C Program to Find the Transpose of a Matrix — Rectangular and In-Place Square

The transpose of a matrix is formed by flipping it over its main diagonal — rows become columns and columns become rows. If the original matrix is of order M×N, its transpose is of order N×M, where element A[i][j] becomes B[j][i]. Matrix A (3×2): Transpose B (2×3): 1 2 1 3 5 3 4 → …

C Program for Matrix Addition, Subtraction and Trace

This program reads two matrices of the same order, computes either their sum or difference (user’s choice), and then finds the trace of the result. The trace of a matrix is the sum of its main diagonal elements (positions where row index equals column index). It is defined for any matrix, not just square ones …

C Program to Evaluate Polynomial Using Horner Method

A polynomial of degree N is an expression of the form: P(x) = ANxN + AN-1xN-1 + … + A1x + A0 The naïve way to evaluate this requires computing each power xk separately, which takes O(N²) multiplications in total. Horner’s method rewrites the polynomial as a nested product that requires only N multiplications and …

C Program to find the average of largest two of the given numbers in the array.

This program reads N integers and finds the two largest values without sorting the array, then computes their average. The key technique: maintain two variables — first (the largest seen so far) and second (the second-largest). Scan each new element and update these two variables in one pass. Time complexity: O(n). Space: O(1) — no …