1. What is C Programming Language?
📘 Technical Definition:
C is a general-purpose, procedural programming language developed by Dennis Ritchie at Bell Labs in 1972. It provides low-level access to memory and is compiled to machine code, making it highly efficient for system programming.
- Created: 1972 by Dennis Ritchie
- Type: Procedural, Structured, Imperative
- Paradigm: Imperative (procedural), structured
- Influenced: C++, Java, C#, Python, PHP
💡 Simple Explanation:
Imagine you want to build a house. You have different tools:
- Python/Java: Like prefabricated walls - easier but less control
- C: Like individual bricks, cement, and tools - more work but complete control
C teaches you how computers actually work - it's like learning car mechanics instead of just driving.
2. Your First C Program
// This is the classic "Hello World" program // Every C program starts with this basic structure #include <stdio.h> // Include Standard Input Output library int main() { // Main function - program starts here printf("Hello, World!\n"); // Print message to screen printf("Welcome to C Programming!\n"); // Another message return 0; // End program successfully }
📝 Understanding Each Line:
| Code | What It Means | Simple Example |
|---|---|---|
| #include <stdio.h> | Adds standard input/output functions | Like opening a recipe book before cooking |
| int main() | Main function where program starts | Like main door of a house - entry point |
| printf("Hello") | Prints text to screen | Like writing on paper |
| \n | New line (Enter key) | Like pressing Enter in typing |
| return 0 | Ends program successfully | Like saying "I'm done cooking" |
💻 Now You Try!
Task: Modify the Hello World program to print your name
// Change this code to print YOUR name #include <stdio.h> int main() { printf("Hello, World!\n"); // ADD YOUR CODE HERE: // printf("My name is: [YOUR NAME]"); return 0; }
Hint: Replace [YOUR NAME] with your actual name
3. Practice Programs (Write These 5)
Based on what you learned, write these 5 programs:
Program 1: Print Your Name
Create a program that prints: "My name is [Your Name]"
Program 2: Welcome Message
Print: "Welcome to C Programming Course"
Program 3: Multi-line Output
Print your name on first line, age on second line, city on third line
Program 4: Pattern Printing
Print this pattern using
printf:
*****
* *
* *
*****
Program 5: Custom Message
Print any message you want with at least 3 lines
4. Viva Questions (Prepare Answers)
Study these questions. Your teacher will ask similar ones in viva.
1. Who created C language and when?
What to study: Dennis Ritchie created C at Bell Labs in 1972.
Simple to remember: "Dennis made C in 1972 for Unix"
2. Why do we need #include <stdio.h>?
What to study: It includes Standard Input Output header file which contains printf() function definition.
Simple to remember: "Without it, printf won't work"
3. What is the purpose of main() function?
What to study: main() is the entry point where program execution begins. Every C program must have one main() function.
Simple to remember: "Program starts from main()"
4. What happens if you forget semicolon (;)?
What to study: Compiler shows syntax error. Semicolon marks end of a statement in C.
Simple to remember: "Computer gets confused without ;"
5. What is the use of \n in printf?
What to study: \n is newline character that moves cursor to next line, similar to pressing Enter key.
Simple to remember: "\n means 'new line'"
5. Multiple Choice Questions
1. C language was developed mainly for:
2. What does printf() function do?
3. Which is the correct way to write main function?
4. What will happen if you write printf("Hello") without #include <stdio.h>?
5. Which company employed Dennis Ritchie when he created C?