C Language Basics Beginner Notes
Variables, data types, operators, expressions, input/output functions, and control flow in C.
C Language Basics — Detailed Notes
C Language Basics is an important chapter in C Programming and is frequently tested in both conceptual and application-based questions. Students should first understand the core definition, then connect the topic with real-life observations and exam patterns.
C is a procedural, middle-level language with manual memory management that compiles to efficient machine code, widely used in systems programming and embedded systems. In school and entrance exams, questions usually check your conceptual clarity, step-wise logic, and ability to avoid common mistakes.
To prepare effectively, break C Language Basics into smaller sub-parts: definition, laws/rules, examples, formulas, and revision questions. After theory, solve short questions, then move to mixed-level numericals or application prompts.
A smart revision strategy is to maintain a one-page summary for C Language Basics. Include important terms, two solved examples, and last-minute checkpoints before exams.
Key Exam Points
- C program structure: includes → main function → statements; compiled with `gcc filename.c -o output`.
- Data types: int (4B), float (4B), double (8B), char (1B). Use `sizeof()` to check.
- Format specifiers: `%d` int, `%f` float, `%lf` double, `%c` char, `%s` string.
- `scanf()` reads input; `printf()` outputs; `&variable` passes address for scanf.
- Operators: arithmetic (+,-,*,/,%), relational (==,!=,<,>), logical (&&,||,!), bitwise.
- Constants with `#define` or `const`; global variables vs local variables scope.
What You Will Learn in C Language Basics
C is a procedural, middle-level language with manual memory management that compiles to efficient machine code, widely used in systems programming and embedded systems.
- C program structure: includes → main function → statements; compiled with `gcc filename.c -o output`.
- Data types: int (4B), float (4B), double (8B), char (1B). Use `sizeof()` to check.
- Format specifiers: `%d` int, `%f` float, `%lf` double, `%c` char, `%s` string.
- `scanf()` reads input; `printf()` outputs; `&variable` passes address for scanf.
- Operators: arithmetic (+,-,*,/,%), relational (==,!=,<,>), logical (&&,||,!), bitwise.
- Constants with `#define` or `const`; global variables vs local variables scope.
Syntax
#include <stdio.h>
int main() {
// variable declarations
int x;
float y;
char ch;
// input
scanf("%d %f %c", &x, &y, &ch);
// output
printf("x=%d, y=%.2f, ch=%c\n", x, y, ch);
return 0;
}Complete Code Example
#include <stdio.h>
int main() {
int a = 10, b = 3;
printf("Sum: %d\n", a + b); // 13
printf("Division: %.2f\n", (float)a/b); // 3.33
printf("Modulus: %d\n", a % b); // 1
// Ternary operator
int max = (a > b) ? a : b;
printf("Max: %d\n", max); // 10
// Swap using XOR
a ^= b; b ^= a; a ^= b;
printf("After swap: a=%d, b=%d\n", a, b); // a=3, b=10
return 0;
}Example
`printf("%d", 10/3)` outputs `3` because integer division truncates the decimal.
Expected Exam Questions — C Language Basics
Q1.What is the difference between `printf` and `scanf`?
Q2.What is the difference between `int` and `float` in C?
Q3.What is the purpose of `#include` and `#define`?
🔘 MCQ Practice — C Language Basics
MCQ 1.What is the output of `printf("%d", 5/2)` in C?
✓ Correct Answer: 2
MCQ 2.Which header file contains `scanf()` and `printf()` in C?
✓ Correct Answer: stdio.h
Download C Language Basics PDF Notes
Get the complete C Language Basics notes as a PDF — free for enrolled students, or browse our public study materials library.