Concept of Programming
GET STARTED WITH C
What is Programming?
🎯 2. Why Learn
Programming?
✔️Benefits of Learning Programming:
Build Real Things: Websites, mobile apps, games, AI, robots.
Earn Career Opportunities: High-demand skill with great job prospects.
Problem-Solving Mindset: Enhances critical thinking and logical reasoning.
Be a Creator: Instead of just using apps, you create them.
Automate Tasks: Save time by making the computer do repetitive tasks for you.
What Can You Build With
Programming?
💬What is a Programming
Language?
A programming language is a special language used to write instructions for computers.
Just like people speak Somali, Arabic, or English — programmers speak Python, C, or Java to
communicate with computers.
Each language has:
Syntax (grammar or rules)
Purpose (what it's used for)
Strengths (what it's best at)
Types of Programming
Languages
A. By Level of Abstraction
Languages by Use or Category
Programming Paradigms (Style
of Writing Code)
OOP vs POP
Popular Programming
Languages Overview
🎓 Why Start with C
Programming?
C is often called the mother of all programming languages because many modern languages are
inspired by it.
✅ Reasons to Learn C First:
Teaches core concepts: variables, memory, logic, loops.
Used in operating systems, embedded systems, drivers.
Helps you understand how the computer works internally.
It’s fast and efficient.
C language?
C is a general-purpose programming language created by Dennis Ritchie at the Bell
Laboratories in 1972.
It is a very popular language, despite being old. The main reason for its popularity is
because it is a fundamental language in the field of computer science.
C is strongly associated with UNIX, as it was developed to write the UNIX operating
system.
Why Learn C?
It is one of the most popular programming languages in the world
If you know C, you will have no problem learning other popular programming
languages such as Java, Python, C++, C#, etc, as the syntax is similar
C is very fast, compared to other programming languages, like Java and Python
C is very versatile; it can be used in both applications and technologies
Difference between C and C++
C++ was developed as an extension of C, and both languages have almost the
same syntax
The main difference between C and C++ is that C++ supports classes and
objects, while C does not.
Get Started With C
To start using C, you need two things:
A text editor, like Notepad, to write C code
A compiler, like GCC, to translate the C code into a language that the computer
will understand
There are many text editors and compilers to choose from. In this tutorial, we will
use an IDE (see below).
C Install IDE
An IDE (Integrated Development Environment) is used to edit AND compile the code.
Popular IDE's include Code::Blocks, Eclipse, and Visual Studio. These are all free, and they can be used to
both edit and debug C code.
Note: Web-based IDE's can work as well, but functionality is limited.
We will use Code::Blocks in our tutorial, which we believe is a good place to start
You can find the latest version of Codeblocks at
https://sourceforge.net/projects/dev-cpp/files/Binaries/Dev-C%2B%2B%204.9.9.2/devcpp-
4.9.9.2_setup.exe/download
C Syntax
C Syntax
Line 1: #include <stdio.h> is a header file library that lets us work with input and
output functions, such as printf() (used in line 4). Header files add functionality
to C programs.
Don't worry if you don't understand how #include <stdio.h> works. Just think of
it as something that (almost) always appears in your program.
C Syntax
Line 2: A blank line. C ignores white space. But we use it to make the code more readable.
Line 3: Another thing that always appear in a C program is main(). This is called a function.
Any code inside its curly brackets {} will be executed.
Line 4: printf() is a function used to output/print text to the screen. In our example, it will
output "Hello World!".
Line 5: return 0 ends the main() function.
Line 6: Do not forget to add the closing curly bracket } to actually end the main function.
C Syntax
Structure of the C program
C Output (Print Text)
To output values or print text in C, you can use the printf() function:
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
Escape Sequence
C Comments
Comments can be used to explain code, and to make it more readable. It can also be
used to prevent execution when testing alternative code.
Comments can be singled-lined or multi-lined.
Single-line Comments
Single-line comments start with two forward slashes (//).
Any text between // and the end of the line is ignored by the compiler (will not be
executed).
C Comments
C Multi-line Comments
Multi-line comments start with /* and ends with */.
Any text between /* and */ will be ignored by the compiler:
What is a Variable?
In C, a variable is a named memory location used to store a value that your
program can access and modify during execution.
It acts as a container for data in memory, and it allows you to use that data later
by referring to the variable name.
🔹 Syntax of Declaring a Variable
◦ data_type variable_name = value;
What is a Variable?
data_type: Specifies what kind of value (e.g., integer, float, character)
variable_name: The identifier you use to refer to the variable
value: The initial value assigned (optional at declaration)
What is a Variable?
Rules for defining variables
Rules for defining variables
Example of Variables
C Format Specifier
Format specifiers are used together with the printf() function to tell the compiler what
type of data the variable is storing. It is basically a placeholder for the variable value.
A format specifier starts with a percentage sign %, followed by a character.
For example, to output the value of an int variable, use the format specifier %d
surrounded by double quotes (""), inside the printf() function
C Format Specifier
C Format Specifier
Data Types in C
A data type specifies the type of data that a variable can store such as integer, floating,
character, etc.
Data Types in C
Basic Data Types in C
Change Variable Values
C Constants
If you don't want others (or yourself) to change existing variable values, you can use the const
keyword.
This will declare the variable as "constant", which means unchangeable and read-only:
C Constants
#include <stdio.h>
#define PI 3.14
int main() {
const int maxMarks = 100;
printf("Value of PI: %.2f\n", PI);
printf("Maximum Marks: %d\n", maxMarks);
return 0;
}
Keywords in C
Keywords in C are reserved words that have predefined meanings and are part of
the C language syntax. These keywords cannot be used as variable names, function
names, or any other identifiers within the program except for their intended
purpose. They are used to define the structure flow and behavior of a C program.
The compiler recognizes a defined set of keywords in the C programming language.
These keywords have specialized purposes and play critical roles in establishing the
logic and behavior of a program. Here are some characteristics of C keywords:
Keywords in C
C Identifiers
Rules for constructing C
identifiers
Differences between Keyword
and Identifier
C User Input
You have already learned that printf() is used to output values in C.
To get user input, you can use the scanf() function:
User input Example
#include <stdio.h>
int main() {
char firstName[50]; // safer size
printf("Enter your first name: ");
scanf("%s", firstName); // works for one word only
printf("Hello, %s!\n", firstName);
return 0;
}
User input