Variables are temporary memory locations that we use to work with mathematical values.  Example-:int a,b,c;.
In C variables must belong to a data type.
Data types in C
In C data type is a property that we add to our variables and finally our variables begin to behave like that data type.
The main data types in C are the following.
integer    -:To store integer values.
float        -:To store fractional values.
character-:To store character values.
However, C supports the following data types in all.
Working with data types:-
In C language data types are used especially in declaring variables. A variable must belong to a data type.
Declaration of variables
When we start main function our first task is to declare variables. Synatax -:[datatype][set of variables];
Example-:int a,b,c;
Here int is a data type.
Rules for creating variable names.
Variables name can be alphanumeric but the start of variables names can never be numeric.
Only dash is allowed ( _ ).
Keywords can never be used as variables.
Since, C is a case sensitive language we should avoid capital letters.
Assigning values to variables.
Syntax -: int a;   a=32000;
float x;   x=3.7;
char z;  z='*';
Write a C program for calculating Simple Interest.
#include< stdio.h> #include< conio.h> void main() { int p,t; float r,si; p=6000; t=3; r=7.8; si=(p*r*t)/100; printf("the si is %f",si); getch(); }
Displaying values of Variables.
When we have to display the value of a variaable we will have to use the printf() statement in a different way. Syntax -: printf(" ", ) Example-: int a; float b; printf("%d%f",a,b);
Write a C program that input three sides of a triangle and displays the area of the triangle.
float a,b,c,s,ar; a=15; b=10; c=5; s=(a+b+c)/2; ar=(s*(s-a)*(s-b)*(s-c)); ar=sqrt(ar); printf("the area is %f",ar); getch(); }
Write a C program to convert celsius to fahreinheit.
#include< stdio.h> #include< conio.h> void main() { float c,f; printf("enter the temperature in celsius"); scanf("%f",&c); f=(9*c+160)/5; printf("the temperature in fahrenheit is %f",f); getch(); }
Write a C program to calculate roots of Quadritic equation.
#include< stdio.h> #include< conio.h> void main() { int x,y; float a,b,c,alp,bit; a=3; b=8; c=4; x=(b*b)-(4*a*c); y=sqrt(x); alp=((-b)+y)/(2*a); bit=((-b)-y)/(2*a); printf("the value of alpha is %f",alp); printf("the value of alpha is %f",bit); getch(); }