Example
int value=250;
char name="Gaurav";
double amount=76.80;
Program to show declarations, assignments and initialization of various types of variables: -
# include <iostream.h>
void main(void)
{
/*.......Declarations....... */
float a, b;
double c, d;
unsigned u;
/*.......Initialization....... */
x = 19298;
int l = 9182769;
/* ....... Assignments.......*/
a= 2345.987;
b= 1928.283647;
d= c =2.20;
u= 54637;
/* .......Displaying.......*/ cout<<"x ="<<x; cout<<"l ="<<l;
cout<<"a ="<<a;
cout<<"d ="<<d;
cout<<"u ="<<"b ="<<"c =\n"<<u<<b<<c;
}
The output will be:
: x = 19298 l = 9182769 a= 2345.987000 d= 1928.283647000000 u= 54637 b=
2.200000 c = 2.200000000000