C variables

A variable is a meaningful name of data storage location in computer memory. When using a variable you refer to memory address of computer. The name of variable can be called identifier.

Example:-
int         age;

Here ‘int’ is data type and ‘age’ is a variable. We say age is a variable of type int and the name (age) of this user-defined variable is called identifier.

char     alphabet_1;

Here we say alphabet_1 is a variable of type char and the name of this variable(alphabet_1) is called identifier.

If still things are not cleared then no need to be worried it will be cleared as we proceed topic by topic.

Now we should check out what is the data type which is used in previous example.
Note:- Syntax of declaring a variable
Data type    variable name;    just like->    int     age;

#include<stdio.h>
int  main()
{
int  gyantoday_age;
printf(“gyantoday age = %d\n”,gyantoday_age);
age  =  65;
printf(“gyantoday age = %d\n”,gyantoday_age);

return 0;
}

When we compile and execute  above C program. The first printf display some garbage value of gyantoday age, because variable gyantoday_age is not initialized at the time of declaration ,so it is good habit to initializa a variable at the time of declaration.

$ ./a.out
gyantoday age = 8290292
gyantoday age =  65

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.