UNDERSTANDI
NG
C
PROGRAMMI
Where Codi ng Logic
Begi ns
NG
WHAT IS
C?
Developed by Dennis
Created
Ritchieat(1972)
Bell Labs to develop the UNIX operating system.
General-purpose and procedural Used for many
applications; focuses on step-by-step instructions. Fast
and efficient Allows low-level memory access; great for
system software and embedded systems.
Foundation for modern
languages Basis for C++, Java,
Portable and widely used Runs on different
C#, and more.
systems with minimal changes; essential in
UNIX,embedded, and OS development.
WHY LEARN
C?
1.Builds strong programming fundamentals and logic
skills.
2.Teaches how computers manage memory and
hardware.
3.Essential for systems, embedded, and
performance-critical applications.
4.Makes learning other languages easier.
5.Highly valued in tech industries.
"What do you think is the
main difference between
C and C++?"
DIFFERENCE BETWEEN C
AND C++
C C+
Procedural language Focuses on Object-oriented + procedural Focuses
step-by-stepinstructions (functions)
+
on objects and classes, supports OOP
concepts like inheritance and
polymorphism More complex, supports
Simpler and closer to hardware higher-level programming Used for
games, large applications, GUI software
Mostly used for system-level programming Supports classes and objects
and embedded systems No classes or
objects
C-
SYNTAX
Every C program starts with header
files, like #include <stdio.h>, to access
standard functions (e.g., printf()). The main()
function is where execution begins —
required in every C program. Curly braces {
} define the start and end of functions or code
blocks. Semicolons ; mark the end of each
statement (like a period in a sentence). Case-
sensitive — Main, main, and MAIN are
different.
C-
STATEMENTS
A statement is an instruction that tells the computer to do something (e.g.,
print, calculate, assign). Common types:
1.Declaration statements — define variables (e.g., int age;).
2.Assignment statements — assign values (e.g., age = 25;).
3.Function call statements — execute functions (e.g.,
printf("Hi!");).
Must always end with a semicolon.
Executed top to bottom, one by one, in
order.
C-
OUTPUT
✅ Step 1: Include the
Always start with #include <stdio.h>. This header file lets you use the
Header
printf() function to show text on the screen.
✅ Step 2: Use printf() to
printf()
Print Textis used to display text. Write your text inside double
quotes, for example: "Hello World!". You can use as many
printf() functions as you want. By default, each printf() keeps
printing on the same line.
✅ Step 3: Use \n to Create New
Add \n inside your text to move to a new line. Think of \n as pressing Enter — it tells
Lines
the program to start printing on the next line. You can place \n anywhere in the text
string to control where the line breaks.
C-
COMMENT
Why use
S are used to explain code and make it easier to understand.
Comments
comments?
They are ignored by the compiler — they do not affect the program output.
Helpful for you and for other people reading your code.
TWO TYPES OF COMMENTS
1.CSingle-line
IN
comments
Starts with //. Used for
short explanations.
2.Multi-line
comments
Starts with /* and ends with */. Used for longer descriptions
or to comment out multiple lines.
C-
What are
VARIABLES
Variables are containers for storing data values. They allow
variables?
you to store, change, and use data in your program. You must
declare a variable before using it.
How to create variables?
Step 1: Choose the data Step
value3: Assign a
type
Decide what kind of data you want to store: Use = to set the value.
int → whole numbers Example: int age = 20;
float → decimal numbers
char → single character
Step 2: Write a variable
Choose a clear, meaningful name.
name
Example: age, score, price, grade
C-DATA
TYPES
Why do we need data
Data types tell what kind of data a variable can store. They help the compiler know how
types?
much memory to set aside and how to handle the data.
BASIC DATA
TYPES
C-DATA
TYPES
What are format
Special placeholders used in printf() to print variable values.
specifiers?
Tell the compiler what type of data to expect..
BASIC FORMAT SPECIFIERS
TYPES
NOTE: ALWAYS USE THE
CORRECT FORMAT
SPECIFIER FOR EACH DATA
TYPE. USING THE WRONG
ONE CAN CAUSE ERRORS
OR PROGRAM CRASHES.
KEY POINTS TO
REMEMBER
It builds strong Header files, Knowing how to This ensures Choosing the
programming skills main() function, display different proper memory correct data type
and helps you and correct syntax data types allocation and saves memory and
understand how (semicolon, correctly is avoids errors. keeps your
computers work at a braces) are critical. essential. program efficient.
low level.
EVERY C USE PRINTF() VARIABLES DATA TYPES
C IS A PROGRAM FOR OUTPUT MUST BE
FOUNDATIONAL DETERMINE
STARTS WITH AND DECLARED WHAT KIND
LANGUAGE. A STRICT UNDERSTAND WITH A DATA OF DATA YOU
STRUCTURE. FORMAT TYPE BEFORE CAN STORE.
SPECIFIERS. USE.