Hello World
Concept: A simple introduction to program structure and printf().
Viva: Why is stdio.h included?
#include <stdio.h>
int main(void) {
printf("Hello World");
return 0;
}Learn C programming step-by-step with original notes, working examples, practical programs, exercises, viva questions and beginner-friendly explanations.
Try:
C is a general-purpose, procedural programming language known for efficiency, portability and close interaction with computer memory. Learning C helps beginners understand core programming ideas such as variables, data types, expressions, selection, repetition, functions, arrays, pointers and structured data.
This site follows a practical learning path: understand the concept, study a small example, type the code yourself, run it, change it, debug errors and then solve a similar problem.
Each topic has its own crawlable page for easier learning and search.
Variables, data types, input/output, operators, comments and the structure of a C program.
Learn decision making and repetition using if, else, switch, for, while and do-while.
Store and process collections of values with one-dimensional and two-dimensional arrays.
Work with character arrays, string input, string length and common string operations.
Break programs into reusable functions and understand parameters, return values and scope.
Understand memory addresses, dereferencing, pointers with arrays and functions, and dynamic memory.
Create custom record types for student, payroll, library and other structured data.
Read and write persistent data using C file streams and standard file I/O functions.
Start with small programs and progress to arrays, strings and data structures.
Try another keyword such as loop, array, or file.
Concept: A simple introduction to program structure and printf().
Viva: Why is stdio.h included?
#include <stdio.h>
int main(void) {
printf("Hello World");
return 0;
}Concept: Variables, input and arithmetic.
Practice: Modify it to calculate average.
#include <stdio.h>
int main(void) {
int a, b;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
printf("Sum = %d", a + b);
return 0;
}Logic: n % 2 == 0 identifies an even integer.
Topic: Selection control structure.
#include <stdio.h>
int main(void) {
int n;
scanf("%d", &n);
if (n % 2 == 0) printf("Even");
else printf("Odd");
return 0;
}Concept: Multiple conditions using if...else if...else.
#include <stdio.h>
int main(void) {
int n;
scanf("%d", &n);
if (n > 0) printf("Positive");
else if (n < 0) printf("Negative");
else printf("Zero");
return 0;
}Logic: Test possible divisors and track whether any divides the number.
Practice: Rewrite it using a function.
#include <stdio.h>
int main(void) {
int n, prime = 1;
scanf("%d", &n);
if (n < 2) prime = 0;
for (int i = 2; i * i <= n; i++)
if (n % i == 0) { prime = 0; break; }
printf(prime ? "Prime" : "Not prime");
return 0;
}Concept: Repetition and accumulation.
#include <stdio.h>
int main(void) {
int n;
unsigned long long f = 1;
scanf("%d", &n);
for (int i = 1; i <= n; i++) f *= i;
printf("%llu", f);
return 0;
}Concept: Traverse an array and keep the current maximum.
#include <stdio.h>
int main(void) {
int a[5], max;
for (int i = 0; i < 5; i++) scanf("%d", &a[i]);
max = a[0];
for (int i = 1; i < 5; i++)
if (a[i] > max) max = a[i];
printf("Largest = %d", max);
return 0;
}Concept: Character arrays and the standard strlen() function.
Safety: Use bounded input such as fgets() for lines.
#include <stdio.h>
#include <string.h>
int main(void) {
char s[100];
fgets(s, sizeof s, stdin);
printf("Length = %zu", strlen(s));
return 0;
}Concept: A function can accept a parameter and return a calculated value.
#include <stdio.h>
float area(float r) {
return 3.14159f * r * r;
}
int main(void) {
float r;
scanf("%f", &r);
printf("%.2f", area(r));
return 0;
}Concept: A structure groups related fields under one type.
#include <stdio.h>
struct Student {
char name[50];
int age;
float marks;
};
int main(void) {
struct Student s = {"Alex", 20, 78.5f};
printf("%s %d %.1f", s.name, s.age, s.marks);
return 0;
}After each lesson, type the example yourself. Change inputs, alter the logic, introduce a small error and debug it. Then solve a similar problem without looking at the answer.
Yes. C gives beginners practice with variables, expressions, control flow, functions, arrays and memory concepts. Start with small programs and increase difficulty gradually.
Read a concept, type an example yourself, compile it, test different inputs, explain the logic aloud and solve a related problem without copying.
Move to control structures, arrays and strings, then functions, pointers, structures and file handling. Projects help connect the topics.
You can begin with a browser-based compiler or mobile coding environment, but a computer becomes more convenient for larger multi-file projects.
Use the C practical questions and C viva questions pages on this site.