Read the download speed in megabits per second (Mbs) and the size of a file in megabytes (MB), calculate the download time for the file. - C Operator

C examples for Operator:Arithmetic Operator

Description

Read the download speed in megabits per second (Mbs) and the size of a file in megabytes (MB), calculate the download time for the file.

Demo Code

#include <stdio.h>

int main(void)
{
  const float BITS_PER_BYTE = 8;
  float download_speed_Mps;
  float file_size_MB;

  printf("Enter the download speed (in megabits/second): ");
  scanf("%f", &download_speed_Mps);
  printf("Enter the file size (in megabytes): ");
  scanf("%f", &file_size_MB);
  printf("%.2f megabits per second, a file of %.2f megabytes"
       " downloads in %.2f seconds.\n", download_speed_Mps, file_size_MB,
       file_size_MB * BITS_PER_BYTE / download_speed_Mps);

  return 0;/*from  w  w  w. j av a2  s  .c  o  m*/
}

Result


Related Tutorials