A variable in C is a name given to a memory location that stores data. It acts like a container for data that your program can manipulate. Each variable must be declared with a specific data type.
๐ Remember: Variables must be declared before they are used.
data_type variable_name;
Or declare and initialize in one line:
data_type variable_name = value;
#include <stdio.h>
int main() {
int age = 20;
float height = 5.9;
char grade = 'A';
printf("Age: %d\\n", age);
printf("Height: %.1f\\n", height);
printf("Grade: %c", grade);
return 0;
}
int, return)marks instead of m to make code more readable.
printf (e.g., using %d for a float)printf๐ง Variable Tip: You can declare multiple variables of the same type in one line:int a = 5, b = 10, c = 15;
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!