Understanding Variables in C Programming: Types and Examples Explained

Souvik Das
1 min read2 days ago

--

Variables and Their Types in C Programming

In C programming, variables are fundamental components that store data values. They allow programmers to manipulate and manage data efficiently.

What is a Variable?

A variable is a named storage location in memory that holds a value which can change during the execution of a program. Variables are crucial for holding data that your program needs to handle

Declaring and Initializing Variables

To use a variable in C, you first need to declare it by specifying its type and name. Initialization involves giving the variable an initial value.

Example:

int age;         // Declaration
age = 25; // Initialization
int score = 100; // Declaration and Initialization

Types of Variables in C

Variables in C can be categorized based on their data type and scope.

Data Types of Variables

  • int: Used to store integers.

int count = 10;

  • float: Used to store single-precision floating-point numbers.

float temperature = 23.5;

  • double: Used to store double-precision floating-point numbers.

double price = 99.99;

  • char: Used to store a single character.

char grade = 'A';

to know scope of variables visit

https://codewaveinsights.blogspot.com/2024/07/understanding-variables-c-programming-types-examples.html

--

--