Unit 3: Fundamentals of C Programming | B. Sc Year: III
🧭 Introduction
After learning about programming languages in Unit 2, it’s time to start with an actual language—C programming.
C is one of the most important foundational programming languages, influencing languages like C++, Java, and Python. It is widely used for:
Operating systems
Embedded systems
Compilers
System software
This unit introduces the basic building blocks of C programming, essential for exams and for understanding later units.
🔑 Key Concepts (Explained Clearly)
1️⃣ What is C Programming Language?
C is a general-purpose, structured, procedural programming language developed by Dennis Ritchie (1970s) at Bell Labs.
Why C is important:
Fast execution
Close to hardware
Portable (machine-independent)
Used for system-level programming
C is often called the mother of programming languages.
2️⃣ Structure of a C Program
A basic C program:
#include <stdio.h>
int main() {
// Program statements
return 0;
}
Parts of a C Program:
Preprocessor Directives –
#include <stdio.h>tells compiler to include required filesmain() Function – Entry point of execution
Statements – Instructions executed by the program
Return Statement –
return 0;indicates successful execution
3️⃣ Compilation and Execution
C programs run in two stages:
🛠 Compilation
Converts C source code to machine code
Checks syntax errors
Produces executable file
▶ Execution
OS loads the executable
Program runs and produces output
Steps:
Preprocessing
Compilation
Linking
Execution
4️⃣ C Character Set
Includes:
Letters: A–Z, a–z
Digits: 0–9
Special Symbols: +, -, *, /, =, <, >, etc.
Whitespace: space, tab, newline
These are used to form words, expressions, and statements.
5️⃣ Tokens in C
Tokens = smallest units of a C program.
Types:
Keywords – Reserved words with special meaning
int, float, if, else, return, forIdentifiers – User-defined names
total, sum, calculateConstants – Fixed values
10, 3.14, 'A'Operators – Symbols performing operations
+ - * / %Punctuators – Symbols like
; , () {} []
6️⃣ Keywords and Identifiers
✅ Keywords
Predefined words in C
Cannot be used as identifiers
Example:
int if while return
✅ Identifiers
Programmer-defined names
Rules:
Begin with letter or underscore
No spaces
Case-sensitive
Example:
int age;
float totalMarks;
7️⃣ Variables and Constants
🔹 Variables
Store data in memory
Declaration:
int num;
Declaration + Initialization:
int num = 10;
🔹 Constants
Values that do not change
Using const:
const int max = 100;
Using #define:
#define PI 3.14
8️⃣ Data Types in C
Basic Data Types:
| Type | Example |
|---|---|
| int | 5, 10 |
| float | 3.14 |
| double | 3.14159 |
| char | 'A' |
Derived Data Types:
Array
Pointer
Structure
Union
9️⃣ Expressions and Operators
An expression combines variables, constants, and operators.
int z = a + b * 2;
Operator Precedence (High → Low):
()* / %+ -=
🔟 Statements in C
Types:
Assignment Statement
x = 10;
Input/Output Statement
printf("Hello");
scanf("%d", &x);
Control Statement
if (x > 5) { ... }
Function Call
sqrt(25);
1️⃣1️⃣ Comments in C
Make programs easy to understand.
Single-line:
// This is a comment
Multi-line:
/* This is
a multi-line
comment */
Ignored by compiler.
1️⃣2️⃣ Escape Sequence Characters
Special characters for output formatting.
| Escape | Meaning |
|---|---|
\n | New line |
\t | Tab |
\\ | Backslash |
\" | Double quote |
Example:
printf("Hello\nWorld");
📝 Important Exam Questions
Define keywords and identifiers with examples
Explain structure of a C program
What are tokens in C?
Define variables and constants
Explain data types in C
What are escape sequence characters?
Explain expressions and operator precedence
🧩 Step‑by‑Step Example
Program: Add Two Numbers
#include <stdio.h>
int main() {
int a = 5, b = 3, sum;
sum = a + b;
printf("Sum = %d", sum);
return 0;
}
Explanation:
Variables declared
Expression evaluated
Result printed
🎯 Exam Tips / Key Points
Write program structure neatly
Use examples for keywords & identifiers
Write 3–4 points for theory answers
Programs should have:
Header file
main()functionreturn 0;
Commented programs get extra marks
✅ Short Summary
Unit 3 covers the fundamentals of C programming, including:
Structure of a C program
Variables, constants, data types
Tokens, keywords, identifiers
Expressions, statements, comments
This unit forms the base for writing C programs, preparing you for input/output, operators, and control statements in later units.
Netra Koirala
Computer Science Educator
Passionate computer science educator and author. Provides free study notes, practical guides, and tutorials for Class 9, 10, 11, 12, and B.Sc CSIT students in Nepal. Years of teaching experience in computer science fundamentals.
LinkedIn ProfileRelated Posts
Loading related posts…
Computer Science notes, tutorials, MCQs, and educational resources for Nepal students. Covering Class 9, SEE preparation, Class 11, Class 12, SLC, programming, DBMS, networking, HTML, JavaScript, PHP, OOP and more.
Featured Post
Grade 10 Computer Science: Specification Grid & Model Questions
Specification Grid & Model Questions of Computer Science | Grade 10 📚 Examination Resource Specification Grid & M...