sizeof Data Types in C – Size of All Types on 32-bit and 64-bit

The sizeof operator in C returns the size in bytes of a type or expression. It is evaluated at compile time and is the standard, portable way to determine how much memory any type occupies on the current platform. Because type sizes vary between 32-bit and 64-bit systems and between compilers, you should always use …

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 …

C program which copies one file contents to another file.

Copying a file in C demonstrates how to combine file I/O functions (fopen, fgetc, fputc, fclose) with command-line arguments to build a practical utility. The program reads filenames from argv, opens both files, copies byte-by-byte, and reports how many bytes were transferred. The original version used conio.h, process.h, void main(), and stored the return value …

2’s Complement of a Binary Number in C

The 2’s complement of a binary number in C is the way modern computers represent negative integers. In an 8-bit system, +5 is stored as 00000101 and −5 is stored as 11111011 (the 2’s complement of 00000101). Using 2’s complement, subtraction becomes ordinary addition and there is only one representation of zero — which is …

C Program to Demonstrate global and internal variables.

Variable scope controls where in a program a variable can be accessed. In C, a variable’s scope is determined by where it is declared: variables declared outside all functions have file scope (global), while variables declared inside a function or block have block scope (local). A third kind — static local variables — persist between …