Prime Number Program in C – Check if a Number is Prime

A prime number program in C checks whether a given integer is prime — divisible only by 1 and itself. Numbers like 2, 3, 5, 7, 11, and 13 are prime; 4, 6, 9, and 12 are not. This page covers two approaches: a basic trial division and an optimized version that skips even numbers, …

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