C Programming Made Easy - Ferdh - 20250503 - 165710 - 0000
C Programming Made Easy - Ferdh - 20250503 - 165710 - 0000
By FerdH
MADE EASY
LET'S EXPLORE TECHNOLOGY
TOGETHER TO LIVE IN THE FUTURE
1
Module 1: Data types & variables Page 5
Introduction to data types: int, float, double,
char, char[], bool
Declaring and initializing variables
Constants and identifiers
Real-life use of variables (e.g., budgeting,
grading systems)
2
Module 4: Control structures Page 21
if, else, else if statements
Nested if statements
switch statements and break
Real-life projects: Grade evaluation,
login system
3
Module 7: Exam Past Questions (Theory + Coding)
Easy: Page 31
Add two numbers
Even/odd checker
Use of if and scanf
Intermediate:
Largest of 3 numbers
for, while, and do...while applications
Factorials and summation
Advanced:
Login system
PIN retry system
Pattern printing
4
What are data types?
Data types tell the computer what kind of
value a variable holds
5
Declaring variables
Syntax: data__type variable_name = value
Example:
Constants in C
A constant value never changes
Declared using const keyword
const float PI = 3.14;
6
Real-life use of variables
Budget calculator: int total = income -
expenses;
Grading system: char grade = 'A';
Temperature sensor: float temp = 37.5;
Practice Questions
Declare an integer to store your age
Create a float variable to store product price
Use a char to represent your grade
Challenge: Store your name using char[]
7
Input and Output in C
Learn how to interact with users using
printf() and scanf()
Example:
scanf("%d", &age);
8
Format specifiers in C
Specifier Used For Example
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("You are %d years old",
age);
return 0;
}
9
Explanation
Asks user to input age
Stores it in variable
Prints
10
Operators in C
Learn how to perform calculations and
comparisons in your programs
Arithmetic Operators
Operator Meaning Example
+ Addition a+b
- Subtraction a-b
* Multiplication a*b
/ Division a/b
11
Logical Operators in C
Programming
Content:
Understand how to make decisions in a
code using &&, ||, and !
Logical operators are used to combine or
reverse conditions in decision-making (if,
while, e.t.c)
Types:
AND (&&)
OR (||)
NOT (!)
Logical AND (&&)
Syntax:
condition1 and condition2
Explanation:
Returns true only if both conditions are true
int loggedIn = 0;
if (!loggedIn) {
printf("Please log in.");
}
output: Please log in.
13
Truth Table
A B A && B A || B !A
0 0 0 0 1
0 1 0 1 1
1 0 0 1 0
1 1 1 1 0
Great question!
14
Equality operators in C
programming
Content:
Used to compare values and check if they
are the same or different
Equality operators are used to compare two
values or.expressions in the conditions (like if
statements)
Main operators:
== Equal to
!= Not Equal to
Equal to (==)
Syntax:
a == b
Explanation:
Checks if the value of a is equal to the value
of b
Returns 1 (true), if equal. 0 (false), if not
int x = 5;
if (x == 5) {
printf("x is equal to 5");
}
output: x is equal to 5 15
Not Equal to (!=)
Syntax:
a != b
Explanation:
checks if the value of b is not equal to
the value of a
Returns 1 (true) if the value is not equal
to. 0 (false) if equal
int y = 10;
if (y != 5) {
printf("y is not 5");
}
output: y is not 5
if (x = 5) // This sets x to 5!
Correct:
16
Relational (comparison) operators
Operator Meaning Example
== Equal to a == b;
!= Not Equal to a != b;
Assignment Operators
Operator Meaning Example
= Assign value a = b;
17
Increment & Decrement
Operators in C
Content:
++ increases the value by 1
-- decreases the value by 1
int x = 5;
x++; // x is now 6
x--; // x goes back to 5
Pre-Increment VS Post-Increment
++x increasing before using
x++ increasing before using
int a = 5;
int b = ++a; // a = 6, b = 6
int c = a++; // c = 6, a = 7
18
Step by step explanation
int a = 5;
int b = ++a; // a = 6, b = 6
int c = a++; // c = 6, a = 7
19
Real-Life Use Cases
Calculating grades, prices, tax
Comparing ages or scores
Checking if user input meets conditions
Adding items in shopping cart
Practice Questions
1. Write a program to calculate the sum,
difference, product and quotient of two
numbers.
20
Control statement in C
Making decisions in programs
What are control statements in C?
They allow your program to make decisions and
control the flow of execution based on
conditions.
Mainly used: if, else, else if
The if statement
if (condition) {
// code runs if condition is
true
}
Example:
21
The if...else statements
if (condition) {
// runs if true
} else {
// runs if false
}
Example:
if (a > 0) {
if (a % 2 == 0) {
printf("Positive
Even");
}
}
Real-life examples
Voting eligibility
Grading systems
ATM PIN validation
Login/password checks
23
Practice Questions
1. Write a program that checks if a number
is positive or negative.
24
Loops in C
Repeating tasks efficiently
while (condition) {
// code runs while condition
is true
}
Example:
int i = 1;
while (i <= 5) {
printf("%d\n", i);
i++;
}
25
The do-while loop
do {
//code runs at least once
}while (condition)
Example:
int I = 1;
do {
printf("%d\n", i);
. i++;
} while(i <= 5);
26
Common Mistakes to Avoid
Infinite loop: forgetting to update the variable
Wrong condition that never becomes false
Misplaced ; after loop declaration
Practice Questions
1. Print numbers from 1 to 10 using a while loop.
2. Use a do-while loop to ask user for a password
until it’s correct.
3. Write a program that prints the multiplication
table of a number.
4. Print even numbers from 1 to 20.
5. Sum the first 10 natural numbers using while
loop.
27
The for loop in C
Example:
Common mistakes
1. Off-by-one errors (looping too much or
too little)
2. Using wrong condition
3. Infinite loop by forgetting update
29
Practice Questions
BUY ME
☕
9038248481
moniepoint
30