Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Introduction to C
History of C Language
C Variables
Variables Types in C
C Identifiers
C Operators
C Comments
ASCII Value C
Constants C
Features of C
Install C Language
Start C Program
Compilation in c
printf() and scanf()
C Data Types
C Keyword
Format Specifier C
Format Specifier part2
Escape Sequence C
Tokens in C
Boolean in C
What are literals?
 


  

 
C Variables
Question Posted on 17 Aug 2020

Home >> Tutorial >> C Language >> C Variables


C Variables
Variable are use to store data and its value can be changed as well as it can be reused many times as we wants. Or we also can say that variable is a name of memory location.

We can also say that it is the way to represent memory location through symbol so that it can be easily identified.

Below is the syntax to define the variable:-

type variable_name;

And below is the example to declare variable:-


int x;
float y;
char z;


Here in above x,y,z are variables. And int, float, char are different data types.

We can also set the value to the variable as per given below syntax:-


int x=10,n=20; //declare 2 varible in single line with values
float y=10.98;
char z='A';



Rules to define variables


Below are 4 most important rules when defining variables in C language:-
(1)We can use alphabets, digits and underscore.
(2)We can start variable with alphabet and underscore only. But it cannot start with a digit.
(3)We cannot use whitespace in variable name.
(4)we cannot use variable name that is reserved word or keyword like int,float, char etc.

valid variable names:-
int a;
int _xyz;
int x20;

Invalid variable names:-
int 2;
int a b;
int long;





Other Important Questions
Features of C
Introduction to C
History of C Language
Install C Language
C Variables







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |