VARIABLE:

Image

The variable is an arbitrary name that is used to name a value or define a value .It is also named as an identifier

EG:…..                   a=5                  ==>     here is the a is variable and   5   is the value of a

RULES FOR DECLARING VARIABLE:

  •     the n number of variables can be declared in single line
  •     after each variable the must be a separation operator
  •     there must not be any space between a single variable declaration
  •     only the underscore symbol which can be used in -between or in front of a single variable as _a or int a_b;
  •     the variable must begin with an alphabet .

CONSTANTS:

constant is a variable which contains the value that cannot be changed till the execution of the program.

eg: const int a=5;

DATA TYPES:

there are some types of data type are as follows :

  • integer
  • floating point
  • character
  • string

INTEGER :

integer is the data type which contains the value like  2 4 6 5 7 2 etc…

the size of an integer is 2 bytes..


INTEGER TYPES:   

  •     int                     ==     2 bytes
  •    shortint             ==      2 bytes
  •  signed int            ==      2 bytes
  • long int                 ==      4 bytes
  • unsigned int        ==      2 bytes
  • unsigned long int==      4 bytes

EG PROGRAM FOR INT:

/*ADDITION OF TWO NUMBER USING INTEGER */

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c;

clrscr();

printf(” enter a & b values:);

scanf(“%d%d”,&a,&b);

c = a+b;

printf(“\n c=%d”,c);

getch();

}

OUTPUT:

enter a & b the value:

2

3

c=5

FLOATING POINT :

float  is the type which contains the value like 2.0,3.5,5.5 etc………….

FLOAT TYPES :

  •       float       == 4 bytes
  •   double       == 8 bytes
  • long double == 10 bytes

EG PROGRAM  FOR FLOAT :

/*addition of two numbers using float */

#include<stdio.h>

#include<conio.h>

void main()

{

float a,b,c;

clrscr();

c=a+b;

printf(“\n c=%f “,c);

getch();

}

OUTPUT:

3.5+5.4=8.9

CHARACTER TYPE:

char is the type which contains the value like ‘a’ ,  ‘@’ ,’$’,etc..

CHAR TYPES:

  • char            == 1 bytes
  • string char ==   assigned size bytes

EG PROGRAM FOR CHAR:

/*using char*/

#include<stdio.h>

#include<conio.h>

void main()

{

char a;

clrscr();

printf(” enter a character value”);

scanf(“%c”,&a);

printf(“a=%c”,a);

getch();

}

OUTPUT:

enter a value :

g

a=g

STRING TYPE:

the string is that consists of values of set of characters..

EG PROGRAM FOR STRING CHARACTER:

/*using string char*/

#include<stdio.h>

#include<conio.h>

void main()

{

char a[20];

clrscr();

printf(“enter a character value:);

scanf(“%s”,&a);

printf(“\n a=%s”,a);

getch();

}

OUTPUT:

enter the a value: sivaram

sivaram

 

 

Unknown's avatar

About mask inventers

think the things big too.....and make different and little playful in the thing that hand to give different in invention
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment