C Tutorial — Learn C Programming
Key takeaway: This free C tutorial teaches you systems programming from scratch — variables, pointers, arrays, functions, structs, and memory management — with practical code examples you can compile and run.
C is a general-purpose, procedural programming language created in 1972. It is used for operating systems, embedded systems, game engines, and performance-critical applications. This tutorial is for beginners, CS students, and developers who want to understand how computers work at a low level.
Last updated: September 2026
do...while Loop in C
The do...while loop is similar to the while loop, but it guarantees that the code block executes at least once, even if the condition is initially false.
do...while Loop Syntax
do {
// code to be executed
} while (condition);#include <stdio.h>
int main() {
int i = 1;
printf("Numbers from 1 to 5:\n");
do {
printf("%d ", i);
i++;
} while (i <= 5);
printf("\n");
return 0;
}Menu-Driven Program Example
#include <stdio.h>
int main() {
int choice;
do {
printf("\n=== MENU ===\n");
printf("1. Say Hello\n");
printf("2. Calculate Square\n");
printf("3. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Hello, World!\n");
break;
case 2: {
int num;
printf("Enter a number: ");
scanf("%d", &num);
printf("Square of %d is %d\n", num, num * num);
break;
}
case 3:
printf("Goodbye!\n");
break;
default:
printf("Invalid choice! Please try again.\n");
}
} while (choice != 3);
return 0;
}while vs do...while
while Loop
- Condition checked before execution
- May not execute at all
- Entry-controlled loop
do...while Loop
- Condition checked after execution
- Executes at least once
- Exit-controlled loop