Chapter 3 Notes
Chapter 3 Notes
• printf("Hello, World!");
Output:
Hello, World!
• int age;
• scanf("%d", &age);
Input: 25
Output: Your age is 25
3. Statement Terminator in C
In C, a statement is terminated using a semicolon (;).
Example:
int a = 5;
printf("%d", a);
Each statement ends with ;, which tells the compiler that the statement is complete.
Types of Operators in C:
5. Arithmetic Operators in C
Used for mathematical calculations.
Types:
1. Addition (+): a + b
2. Subtraction (-): a - b
3. Multiplication (*): a * b
4. Division (/): a / b
Example:
int a = 10, b = 3;
Types:
Example:
int a = 5;
Example:
printf("a is 10");
Uses:
Example:
float pi = 3.14;
9. Format Specifiers in C
Format specifiers define the type of data in printf() and scanf().
\n New Line
\t Tab Space
\\ Backslash
Example:
printf("Hello\nWorld");
Output:
Hello
World
Compare values.
Conditional Operator (? :)