


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An essential self-study module covering the absolute basics of C programming. Learn how variables store data, master foundational data types (int, float, double, char), and explore syntax rules using highly scannable tables, conceptual analogies, and ready-to-run code examples. Perfect for beginners looking to understand the "blueprint language" of modern computing.
Typology: Summaries
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Basics of C Programming โ Self Study Notes What is C? C is one of the oldest and most powerful programming languages, created in the 1970s. Think of C as the blueprint language โ almost every modern language (Python, Java, JavaScript) borrowed ideas from it. Learning C is like learning to drive a manual car: harder at first, but you understand how the engine works. Variables โ Labelled Boxes in Your Brain A variable is a named storage location in memory. Think of it like a labelled jar in your kitchen โ the label is the variable name, and whatever is inside is its value. int age = 25; Jar analogy: The jar is labelled age. Inside it, you've placed the number 25. You can empty it and refill it with a different number anytime. Rules for naming variables:
int students = 42; int floors = 3; Imagine counting floors in a building โ you say 3, not 3.5. Memory used: 4 bytes (can hold roughly โ2 billion to +2 billion)
2. float โ Decimal Numbers (Single Precision) Real world: Price of groceries, your temperature reading, a petrol bill. float price = 89.99; float temperature = 36.6; A thermometer shows 36.6ยฐC โ not just 36. That decimal matters. Memory used: 4 bytes (~6โ7 decimal digits of precision) 3. double โ Decimal Numbers (High Precision) Real world: Scientific calculations, GPS coordinates, bank balances. double distance = 384400.756; // Distance to the Moon in km double balance = 1000250.8875; When NASA calculates a rocket's path, they can't round off. Every decimal counts. Memory used: 8 bytes (~15 decimal digits of precision) 4. char โ A Single Character Real world: A grade on your report card, a gender field (M/F), a single letter in a word. char grade = 'A'; char initial = 'R';
This is like a student's profile card โ age, marks, fees, and grade all stored neatly in their own labelled compartment. Quick Reference Table Data Type Real World Example Format Specifier Size int Number of chairs %d 4 bytes float Petrol price %f 4 bytes double Bank account balance %lf 8 bytes char Blood group (A, B) %c 1 byte Key Takeaways