C Program To Demonstrate Linear search

Linear search (also called sequential search) is the simplest searching algorithm: start at the first element, compare each element to the key, and stop when you find a match or exhaust the array. It makes no assumption about the data being sorted. It runs in O(n) time and O(1) space — no extra memory needed …

C program to find the value of sin(x)

This C program computes the value of sin(x) by summing its Taylor series up to a given accuracy, then compares the result with the built-in sin() library function. It’s a classic exercise in loops, floating-point math, and how a computer approximates trigonometric functions. The Sine Series The Taylor series for sine (with x in radians) …

C program to find the sum of ‘N’ natural numbers.

The natural numbers are the positive integers: 1, 2, 3, 4, 5, … Their sum from 1 to N can be computed two ways: a simple loop that adds each number, or the Gauss formula N×(N+1)/2 that gives the answer in O(1) time without any loop. This post shows both, explains why the formula works, …

C Program to Check Whether a Given Integer is Positive or Negative

A number is positive if it is greater than zero, negative if it is less than zero, and zero is neither. This is one of the most fundamental checks in programming — it shows up in input validation, physics simulations, financial calculations, and signal processing. This program handles all three cases with a clear if-else …

C Program to Check Whether a Given Integer is Odd or Even

An integer is even if it is divisible by 2 with no remainder, and odd if dividing by 2 leaves a remainder of 1. Zero is even. Negative integers follow the same rule: −4 is even, −7 is odd. This program uses the modulo operator % to determine parity in a single if-else check. Number …

C Program To Swap Two Variables

Swapping two variables is one of the most common operations in sorting, data structure manipulation, and algorithm implementation. There are three standard methods: using a temporary variable (clearest), arithmetic (no temp, but overflow risk), and XOR bit manipulation (no temp, no overflow, but tricky for same-variable self-swap). All three produce the same result — understanding …