C Program to find whether the given character is Vowel or Consonant

The five English vowels are: a, e, i, o, u (both upper and lowercase). Every other alphabetic character is a consonant. Non-alphabetic characters (digits, punctuation, spaces) are neither vowel nor consonant. This program uses the <ctype.h> functions isalpha() and tolower() for clean, case-insensitive classification. The original post used a Gist shortcode ([gist id=”7112441″]) that no …

Simple Calculator in C Using Switch Statement – All 4 Operations

A simple calculator in C using switch statement reads an operator character (+, -, *, /) and dispatches to the correct arithmetic operation. The switch statement is ideal here: each operator maps to exactly one case, with a default branch catching anything unsupported. This program also demonstrates proper division-by-zero handling — an error that causes …

Binary Search in C – Iterative and Recursive with Example

Binary search in C finds a target value in a sorted array by repeatedly halving the search space. At each step it compares the target against the middle element: if they match, the search is done; if the target is smaller, discard the right half; if larger, discard the left half. This gives O(log n) …

Decimal to Binary in C – Conversion Program with Example

Decimal to binary conversion in C uses the repeated-division-by-2 algorithm: divide the number by 2, record the remainder (0 or 1), then divide again until the quotient reaches 0. Reading the remainders from bottom to top gives the binary equivalent. This conversion is foundational for understanding how computers store integers — every value you work …

C Program to Find Largest of 3 Numbers – 3 Methods

Finding the largest of three numbers is one of the first real decisions a C program has to make. It sounds simple, but it teaches you conditional logic, how the if-else ladder works, and why wrapping repeated logic in a function pays off immediately. This post shows three approaches — a plain if-else, a ternary …

C Program to Find Array c Where c[i] = a[i] + b[n-1-i]

Given two integer arrays a[] and b[] of n elements, compute a third array c[] where each element is c[i] = a[i] + b[n-1-i]. The key insight is the index n-1-i: when i=0 it selects the last element of b, when i=n-1 it selects the first. This “reverse pairing” adds each element of a to …