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 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 Sum and Average of an Array

C Program to Find Sum and Average of an Array This program reads N integers (positive, negative, and zero) into an array and computes three values: the sum of negatives, the sum of positives, and the average of all elements. Algorithm Read N (array size) from the user. Read N integers into the array one …

GCD and LCM of Two Numbers in C – Euclid’s Algorithm

The GCD (Greatest Common Divisor) and LCM (Least Common Multiple) of two integers in C are most efficiently found using Euclid’s algorithm. The algorithm repeatedly replaces the larger number with the remainder of dividing the two numbers until the remainder is zero — what remains is the GCD. The LCM then follows from the identity …

Numbers Divisible by 7 in C – List, Count, and Sum

Finding all integers in a range that are divisible by a given number is a classic loop exercise. The key tool is the modulo operator % — if i % 7 == 0, then i is exactly divisible by 7 with no remainder. This post shows two programs: one for the classic 100–200 range, and …