Byte to KILOBYTE conversion in c++

nirveshverma 1 Tallied Votes 5K Views Share

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.

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    
    long double byte;
    long double kilobyte;
    long double megabyte;
    long double gigabyte;
    
    
    cout << "Enter the byte value";
    cin>>byte;
    
    kilobyte = byte / 1024;
    megabyte = kilobyte / 1024;
    gigabyte = megabyte /  1024;
    
    
    
    cout <<  byte << " Equal to  " << kilobyte << " Kilobyte's "<<"\n";
  
  
    cout <<  byte << " Equal to  " << megabyte << " Megabyte's "<<"\n";
   
    
    cout <<  byte << " Equal to  " << gigabyte << " Gigabyte's "<<"\n";
    
    
  
  

    
    system("pause");
    return 0;
}
K0ns3rv 0 Junior Poster in Training

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

commented: gud +0
nirveshverma -1 Light Poster

thanks for your comment

tkud 0 Posting Whiz in Training

Nice code, good for beginners to understand and get a foot on c++.
u did good,nandux8.

nirveshverma commented: gud +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.