C Variables


What is Variables?

A variable in C is like a container used to store data during program execution. It holds a value that can change while the program runs.

Imagine you want to remember a number—like a score or age. You give that number a name like score or age, and your computer remembers it using that name. That's a variable.


Types of Variables in C

Each variable needs a type, which tells the computer what kind of information it holds:

TypeDescriptionExample
intWhole numbersint marks = 90;
floatDecimal numbersfloat price = 99.5;
charSingle letterschar grade = 'A';
doubleLarge decimal numbersdouble pi = 3.14159;
boolTrue/false values (with stdbool.h)bool isReady = true;

How to Declare a Variable

int age; 
float weight; 
Char initial; 

This means you're telling C: "I will use a number (age), a decimal (weight), and a character (initial)."


How to Assign Values

age = 25; 
weight = 65.5; 
Initial = 'S'; 

You can also do both steps in one line:

int age = 25;

Strict Notes – Must Remember

  • Declaration before usage is compulsory.
  • Names must begin with a letter or underscore (_).
  • No spaces or special characters (except _) in identifiers.
  • C is case-sensitive – Age and age are different.
  • Cannot use reserved words like int, while, return as variable names.
  • Use semicolon (;) at the end of every statement.
  • Type mismatch (e.g., assigning float to int) may cause incorrect results.
  • Variable names should be meaningful to improve code readability.
  • Re-declaration in the same block is an error.
  • Uninitialized variables may contain garbage values.

Unique Vocabulary

  • Identifier
  • Reserved
  • Literal
  • Scope
  • Memory
  • Instruction
  • Precision
  • Dataflow
  • Constant
  • Symbol

Final Thoughts

C provides a versatile set of types: from raw numbers to flexible memory-sharing structures. Understanding how each works allows you to optimize space, enhance readability, and increase code efficiency


Prefer Learning by Watching?

Watch these YouTube tutorials to understand C Tutorial visually:

What You'll Learn:
  • 📌 #2: C Variables and Print Output | [2025] C Programming for Beginners
  • 📌 Introduction to Variables
Previous Next