WAP USING OPERATOR OVERLOADING TO ENTER THE MEMORY IN BYTES AND CONVERT THEM INTO MB,KB & BYTES
#include<iostream.h>
#include<conio.h>
class memory
{
long int b,kb,mb;
public:
memory(long int d)
{
b=d%1024;
d=d/1024;
kb=d%1024;
d=d/1024;
mb=d%1024;
}
void disp()
{
cout<<"MB::"<<mb<<endl
<<"KB::"<<kb<<endl
<<"Bytes::"<<b;
}
};
void main()
{
clrscr();
long int bt;
cout<<"Enter the memory in bytes::";
cin>>bt;
memory m=bt;
m.disp();
getch();
}
#include<iostream.h>
#include<conio.h>
class memory
{
long int b,kb,mb;
public:
memory(long int d)
{
b=d%1024;
d=d/1024;
kb=d%1024;
d=d/1024;
mb=d%1024;
}
void disp()
{
cout<<"MB::"<<mb<<endl
<<"KB::"<<kb<<endl
<<"Bytes::"<<b;
}
};
void main()
{
clrscr();
long int bt;
cout<<"Enter the memory in bytes::";
cin>>bt;
memory m=bt;
m.disp();
getch();
}

No comments:
Post a Comment