The First C Program
Introducing the concept of writing a simple C program to calculate simple interest.
Form of a C Program
Each instruction is a separate statement.
Statements must appear in the desired execution order.
Blank spaces for readability.
All statements in lowercase.
C is a free-form language.
Statements end with a semicolon (;).
Comments in a C Program
Comments clarify the purpose of the program or statements.
Comment format: /* comment text */
Comments are for programmer understanding.
Comments cannot be nested.
Multi-line comments allowed.
ANSI C also supports // for comments.
What is `main()`?
`main()` is a C function.
It contains a set of statements.
`main()` always returns an integer.
0 indicates success; non-zero indicates failure.
`void main()` is non-standard.
Variables and Their Usage
Variables must be declared before use.
Example: int p, n; float r, si;
Use variables in expressions.
printf() and Its Purpose
C uses `printf()` to display output.
Include <stdio.h>
to use `printf()`.
`printf()` format: printf("
Format specifiers: %f, %d, %c.
Escape sequence: '\n' for a newline.
Examples of `printf()`
Illustrate different uses of `printf()` with examples.
Questions and Answers
Open the floor for questions.