C Program to Copy String Without Using strcpy()
Manual copy loop.
Sample
Begin with printing, swapping, sizes, character checks, and simple control flow. These concise programs build confidence with C syntax and the standard library.
Manual copy loop.
Sample
Prints a greeting to the console.
Hello, World!
Demonstrates integer I/O.
You entered: 123
Adds two integers and prints the sum.
Sum = 8
Multiplies two floats.
Product = 10.00
Prints ASCII of a character.
ASCII of A = 65
Integer division and modulo.
Quotient = 6 Remainder = 2
Uses sizeof operator.
sizeof(char) = 1 sizeof(int) = 4 sizeof(float) = 4 sizeof(double) = 8
Shows long type usage.
long x = 1234567890
Swaps using temp variable.
a = 4, b = 3
Checks parity using modulo.
7 is odd
Checks vowel set.
e is vowel
Finds max of three.
Largest = 17
Quadratic formula for ax^2+bx+c.
Roots: 2.00, 1.00
Checks leap year rules.
2024 is leap year
Checks sign.
-10 is negative
Uses isalpha.
# is not alphabet
Iterates ASCII letters.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Computes population std dev.
StdDev = 2.00
Cyclic swap a->b->c.
a=3 b=1 c=2
Uses malloc for array.
Largest = 9
Counts frequency of a given char.
'l' occurs 3 times
Classifies characters.
Vowels=3 Consonants=7 Digits=3 Spaces=2 Others=1
Filters only letters.
HllWrld
Uses strlen.
Length = 5
Uses strcat safely.
Hello World
Sorts array of strings.
apple banana cherry
Defines struct and prints.
Alice 20 92.5
Adds feet-inch distances.
9 feet 7 inch
Adds complex numbers.
4.0 + 5.0i
Subtracts times with borrow.
01:19:40
Allocates struct via malloc.
1 3.14
Writes a line to file.
Written.
Reads first line of file.
First line: Hello file
Prints contents of source via argv[0].
(program source content)
Simple star pyramid.
* *** ***** ******* *********
gcc or clang. For example: gcc program.c -o program && ./program. On Windows, you may use MinGW or tdm-gcc; on macOS/Linux, the default package managers provide compilers.
C remains one of the most influential programming languages, powering operating systems, embedded devices, and performance-critical software. Practicing small, focused programs builds muscle memory and clarity with syntax and concepts such as data types, control flow, functions, arrays, pointers, and memory management.
On this page, you will find clean, well-formatted examples that compile across platforms. Each example includes a short description and expected output so you can quickly verify your understanding. Explore the topics via the sidebar and extend the code to experiment further.
Whether you’re preparing for interviews, working through coursework, or refreshing fundamentals, these examples offer a practical path to mastering C. Bookmark the page and return often to continue improving.