What is Variables in C ?

Variables are names that are used to store values. It can take different values but one at a time. A data type is associated with each variable & it decides what values the variable can take. When you decide your program needs another variable, you simply declare (or define) a new variable and C makes sure you get it. You declare all C variables at the top of whatever blocks of code need them. Variable declaration requires that you inform C of the variable’s name and data type. Syntax – datatype variablename;

Example:
int page_no;
char grade;
float salary;
long y;

Declaring Variables:

There are two places where you can declare a variable:

After the opening brace of a block of code (usually at the top of a function)

Before a function name (such as before main() in the program) Consider various examples: Suppose you had to keep track of a person’s first, middle, and last initials. Because an initial is obviously a character, it would be prudent to declare three character variables to hold the three initials. In C, you could do that with the following statement:

Initialization of Variables
When a variable is declared, it contains undefined value commonly known as garbage value. If we want we can assign some initial value to the variables during the declaration itself. This is called initialization of the variable

Eg-
int pageno=10;
char grade=’A’;
float salary= 20000.50;

Expressions
An expression consists of a combination of operators, operands, variables & function calls. An expression can be arithmetic, logical or relational. Here are some expressions:

An important property of C is that every C expression has a value. To find the value, you perform the operations in the order dictated by operator precedence.

Statements
Statements are the primary building blocks of a program. A program is a series of statements with some necessary punctuation. A statement is a complete instruction to the computer. In C, statements are indicated by a semicolon at the end. Therefore

legs = 4
is just an expression (which could be part of a larger expression), but
legs = 4; is a statement.

What makes a complete instruction? First, C considers any expression to be a statement if you append a semicolon. (These are called expression statements.) Therefore, C won’t object to lines such as the following:

8;
3 + 4;

However, these statements do nothing for your program and can’t really be considered sensible statements. More typically, statements change values and call functions:

x = 25;
++x;
y = sqrt(x);

Although a statement (or, at least, a sensible statement) is a complete instruction, not all complete instructions are statements. Consider the following statement:

x = 6 + (y = 5);

In it, the subexpression y = 5 is a complete instruction, but it is only part of the statement. Because a complete instruction is not necessarily a statement, a semicolon is needed to identify instructions that truly are statements.

Compound Statements (Blocks)
A compound statement is two or more statements grouped together by enclosing them in braces; it is also called a block. The following while statement contains an example:

ABOUT US - Team Behind This Plateform

We Are Engineering Graduate ,Tutor and Technology lover, Our Primary Main Area of interest is Computer Science And Electronics & Communication Technology

We are trying to make all those topics more simple and easy to understand,So that it will help students to learn it very quickly in limited amount of time like Last Peak hours of their Extermination,its like last time revision Notes. we also have provided the depth knowledge of some topics which really require more words to explain.

Other Area of this online platform contains "Online MCQ based Tests / Multiple choice Questions" ,Which can Helps readers to crack Various competitive Exams

Computer subject become necessary for all the students from various branches, and this plateform will provide them all the required knowledge to answer the Questions correctly in the various competative exams