C++ PROGRAMS
//
CONSTANTS DECLARATION
#include <iostream.h>
#include<conio.h>
void
main()
{
int
i;
char
ch;
char
str[34];
float
f;
clrscr();
cout<<"ENTER
AN INTEGER : ";
cin>>i;
cout<<"ENTER
A CHARACTER : ";
cin>>ch;
cout<<"ENTER
THE STRING : ";
cin>>str;
cout<<"ENTER
A FLOAT : ";
cin>>f;
cout<<"\nCONSTANTS
"<<endl;
cout<<"\nINTEGER
: " <<i<<endl;
cout<<"\nCHARACTER
: "<<ch<<endl;
cout<<"\nSTRING
: "<<str<<endl;
cout<<"\nFLOAT
: " <<f<<endl;
getch();
}
/*OUTPUT
ENTER
AN INTEGER : 7
ENTER
A CHARACTER : S
ENTER
THE STRING : SUNIL
ENTER
A FLOAT : 6.3
CONSTANTS
INTEGER
: 7
CHARACTER
: S
STRING
: SUNIL
FLOAT
: 6.3
*/
_____________http://sundcs.blogspot.com/____________
//
TO DISPLAY THE SIZE OF VARIOUS DATA TYPES AVAILABLE.
#include<iostream.h>
#include<conio.h>
void
main ()
{
int x=25;
clrscr
();
cout<<"sizeof(char)";
gotoxy(x,1);
cout<<sizeof(char)<<endl;
cout<<"sizeof(signed
char)"; gotoxy(x,2);
cout<<sizeof(signed
char)<<endl;
cout<<"sizeof(unsigned
char)"; gotoxy(x,3);
cout<<sizeof(unsigned
char)<<endl;
cout<<"sizeof(int)";
gotoxy(x,4);
cout<<sizeof(int)<<endl;
cout<<"sizeof(signed
int)"; gotoxy(x,5);
cout<<sizeof(signed
int)<<endl;
cout<<"sizeof(unsigned
int)"; gotoxy(x,6);
cout<<sizeof(unsigned
int)<<endl;
cout<<"sizeof(short)";
gotoxy(x,7);
cout<<sizeof(short)<<endl;
cout<<"sizeof(signed
short)"; gotoxy(x,8);
cout<<sizeof(signed
short)<<endl;
cout<<"sizeof(unsigned
short)"; gotoxy(x,9);
cout<<sizeof(unsigned
short)<<endl;
cout<<"sizeof(short
int)"; gotoxy(x,10);
cout<<sizeof(short
int)<<endl;
cout<<"sizeof(float)";
gotoxy(x,11);
cout<<sizeof(float)<<endl;
cout<<"sizeof(short
float)"; gotoxy(x,12);
cout<<sizeof(short
float)<<endl;
cout<<"sizeof(long)";
gotoxy(x,13);
cout<<sizeof(long)<<endl;
cout<<"sizeof(signed
long)"; gotoxy(x,14);
cout<<sizeof(signed
long)<<endl;
cout<<"sizeof(unsigned
long)"; gotoxy(x,15);
cout<<sizeof(unsigned
long)<<endl;
cout<<"sizeof(long
float)"; gotoxy(x,16);
cout<<sizeof(long
float)<<endl;
cout<<"sizeof(double)";
gotoxy(x,17);
cout<<sizeof(double)<<endl;
cout<<"sizeof(long
double)"; gotoxy(x,18);
cout<<sizeof(long
double)<<endl;
getch
();
}
/*OUTPUT
sizeof(char)
1
sizeof(signed
char) 1
sizeof(unsigned
char) 1
sizeof(int)
2
sizeof(signed
int) 2
sizeof(unsigned
int) 2
sizeof(short)
2
sizeof(signed
short) 2
sizeof(unsigned
short) 2
sizeof(short
int) 2
sizeof(float)
4
sizeof(short
float) 4
sizeof(long)
4
sizeof(signed
long) 4
sizeof(unsigned
long) 4
sizeof(long
float) 8
sizeof(double)
8
sizeof(long
double) 10
*/
_____________________http://sundcs.blogspot.com/_________________
No comments:
Post a Comment