Variables in C Programming

Variable names in C Language are the names given to locations in memory. These locations can be an integer, characters, or real constants. In addition, a variable type can only hold the same constant type. In this lesson, we will learn how to work with Variables in C Programming.

Rules for Variable naming

The first character in a variable name must be an underscore or alphabet. Here are the rules, with some examples,

  • A variable name is a combination of alphabets 1 to 31, digits, or underscores.

Variables in C Programming

  • No special symbol in a variable name is valid, except the underscore.

Valid and Invalid Variable Names in C Programming

  • No comma is allowed in a variable name.
  • In addition, no blank space is valid.

Always try to create meaningful names. For example, the variable names for calculating the results of students can be given variable name results.

Variable Declaration

Declaration of a variable in C language is quite easy. The following is the syntax showing how to declare variables in C programming,

The valid variable declaration examples are shown below. Here, int, char, and float are datatypes,

The preceding examples show how a variable is declared, wherein a datatype precedes the variable name.

The following examples demonstrate the usage of variables in C Programming,

Variables in C Programming

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others:


For Videos, Join Our YouTube Channel: Join Now


Read More:

Tokens in C Programming
Operators in C Programming
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading