C Program to find whether the given year is leap or not.

A leap year has 366 days instead of 365, with February 29 as the extra day. The Gregorian calendar uses a four-part rule to decide whether a year is a leap year. This rule is one of the most commonly tested C interview questions because it requires a compound conditional with exactly the right operator …

C Program to Generate N Fibonacci Terms Using Array

The Fibonacci sequence starts with 0 and 1; each subsequent term is the sum of the two that precede it: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … This program generates the first n terms by storing them in an array, then printing the full sequence. Using an array — rather than …

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 …

C Program to Sort an Array Using Bubble Sort — With Optimisation and Complexity

Bubble Sort is the simplest sorting algorithm to understand and implement. It works by repeatedly comparing adjacent elements and swapping them if they are in the wrong order. After each pass, the largest unsorted element has “bubbled up” to its correct position at the end — just like air bubbles rising to the surface of …

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) …