Introduction to C Language and Programming (Part II How To Use Variables)
How to use Variables
When you are programming, you want to show and store information,
to do that, you have to have Variables, you can input data and store in
variables. In programming, Few Variables types are available, there are some choices,
it will depend on the data type which you are going to use and input to a
variable.
Ex:
Int = Int can store integers (Numbers can be stored but it
cannot store decimal numbers)
Char = Char and store single character
Float = float can store number with decimal
You tell the compiler that I’m going to use this variable as
this type or that type or whatever, then only compile can identify about the
variable.
Syntax of the declaring a variable:
<Variable type> <Name of the variable>;
Ex :
int myFrist;
int xy123;
char my1, my2, myName;
· Here we have declared three variables by dividing
commas, you can have multiple variables, but names must be different.
char my1, my2, myName;
When we are naming the variables, you have to use camel case.
It means when we are declaring a variable, we have to start the name of the variable
by using Simple letter, but we can combine two words by using Capital letter as
like below, you will see the camel :)
helloWorld
youAre
sriLanka
helloWorld
youAre
sriLanka
I hope you could have an idea about it, and also we must
know, we cannot declare a variable starting from a number like below.
Int 123xy;
Char 124gh;
Those are wrong and cannot use as variables, after declare
the variable, you have to close it by using semicolon, and then it will ready
for using.
#include <stdio.h>
int main()
{
int x;
x = 10;
printf( "The
Number is %d: ", x);
getchar();
return 0;
}
When you are declaring a variable, you must know, you have
to declare it first, or else it won’t be able to show the information that you
have stored in the variable, and also there will be an error, because you
cannot use a variable name without declare it first, try below example and you
will understand.
Below program is not valid that is only an example:
#include <stdio.h>
int main()
{
printf( "The
Number is %d: ", x);
int x = 10;
getchar();
return 0;
}


This is very interesting post and I learned so much from your blog. Do posting more.
ReplyDeleteccna Training institute in Chennai
ccna institute in Chennai
gst classes in Chennai
ReactJS Training in Chennai
Salesforce Training in Chennai
Tally course in Chennai
Web Designing Course in Chennai
ux design course in Chennai
Web Designing Course in anna nagar
ReplyDeleteThat's great about what you have expressed in this clear cut blog in sense of SEO , and yes this would make a wonderful blog. Here's a lot of technical and educational information plotted as in your writings, it was more understandable and easy to read.
Sounds like something people would want to read this blog really!keep writing…
seo training classes
seo training course
seo training institute in chennai
seo training institutes
seo courses in chennai
seo institutes in chennai
seo classes in chennai
seo training center in chennai