• Home
  • Variables in C Language

Variables in C Language

In C, variables are used to store data values in a program. A variable has a name, a type, and a value. The name of a variable is used to refer to it in the program, and the type specifies the kind of data that it can hold.

To declare a variable in C, you must specify its type and name. For example:

int age;

float price;

char grade;

You can also initialize a variable when you declare it by assigning it a value. For example:

int age = 25;

float price = 9.99;

char grade = ‘A’;

Once a variable has been declared, you can use it in your program by referencing its name. For example:

age = 26;

price = price + 5.99;

grade = ‘B’;

It is important to choose descriptive and meaningful names for variables to make your code easier to read and understand. It is also important to use the correct data type for a variable based on the kind of data it will hold. Using the correct data type can help to ensure that your code is efficient and free of errors.