C program to implement bit flipping.

Write a C program to implement bit flipping.C Program to setbits(x,p,n,y) that returns x with the n bits that begin at position p set to the rightmost n bits of y, leaving the other bits unchanged in the least number of lines.Bit flipping or flip bit is the complement(~) of bits. i.e., 0 to 1 …

Print Factors of a Number in C – O(√n) Algorithm

A C program to print factors of a number finds all positive integers that divide the number evenly (with no remainder). These are also called divisors. For 12: the factors are 1, 2, 3, 4, 6, and 12. Every number has at least two factors: 1 and itself. A number with exactly two factors is …

Fibonacci Series in C – Iterative, Recursive, and Array Methods

The Fibonacci series in C is a sequence where each number is the sum of the two preceding ones, starting from 0 and 1: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … This page covers three approaches — iterative series printing, a recursive function, and a side-by-side comparison of their time and …

C Program to demonstrate the ‘fgets’ function.

Program to demonstrate the ‘fgets’ function. The program will count the number of lines in a file. This is a function of the UNIX command ‘wc’. Read more about C Programming Language . /************************************************************ You can use all the programs on www.c-program-example.com* for personal and learning purposes. For permissions to use the* programs for commercial …

extern Keyword in C – Declaration, Definition, and Multi-File Programs

The extern keyword in C declares that a variable or function exists — but is defined somewhere else. It tells the compiler “trust me, this symbol is defined in another translation unit; the linker will resolve it.” Understanding extern is essential for any multi-file C program, and confusing declaration with definition is one of the …

C Program to demonstrate the ‘atof’ and ‘gets’ functions.

Converting strings to numbers is a fundamental task in C — every value read from scanf, fgets, or command-line arguments arrives as a string and must be explicitly converted. The standard library in <stdlib.h> provides three simple conversion functions: atoi() (string to int), atol() (string to long), and atof() (string to double/float). For robust error …