Byte to KILOBYTE conversion in c++

Please support our C++ advertiser: Intel Parallel Studio Home
nandux8 nandux8 is offline Offline Oct 15th, 2009, 6:17 am |
1
HEy
Buddies in early morning i want to calculate that exchange during download & you very well known that it is shown in byte so just i am g with c++ and play a game for writing this.
thanks
enjoy it.
It's very easy and handy with simple logic.
Quick reply to this message  
C++ Syntax
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8. long double byte;
  9. long double kilobyte;
  10. long double megabyte;
  11. long double gigabyte;
  12.  
  13.  
  14. cout << "Enter the byte value";
  15. cin>>byte;
  16.  
  17. kilobyte = byte / 1024;
  18. megabyte = kilobyte / 1024;
  19. gigabyte = megabyte / 1024;
  20.  
  21.  
  22.  
  23. cout << byte << " Equal to " << kilobyte << " Kilobyte's "<<"\n";
  24.  
  25.  
  26. cout << byte << " Equal to " << megabyte << " Megabyte's "<<"\n";
  27.  
  28.  
  29. cout << byte << " Equal to " << gigabyte << " Gigabyte's "<<"\n";
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. system("pause");
  37. return 0;
  38. }
1
K0ns3rv K0ns3rv is offline Offline | Oct 15th, 2009
Nice it only has two flaws.
Change the system("pause") to cin.get();
And put a while loop around it all so you can do it repeated times.


//K0s3rv
 
0
nandux8 nandux8 is offline Offline | Oct 15th, 2009
thanks for your comment
 
1
tkud tkud is offline Offline | Oct 15th, 2009
Nice code, good for beginners to understand and get a foot on c++.
u did good,nandux8.
 
 

Message:


Similar Threads
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC