#include <stdio.h>
int byte2bits(int x);
int bits2byte(int x);
int main() {
int choice, answer, byte, bit;
printf("[1] Byte to Bits [8] Bits to Byte [0] Exit\n");
printf("Enter Choice:");
scanf("%d", &choice);
switch(choice)
{
case 1:printf("Enter the number of byte:");
scanf("%d", &byte);
answer=byte2bits(byte);
printf("%d byte/s = %d bit/s", byte, answer);
break;
case 8:printf("Enter the number of bits:");
scanf("%d", &bit);
answer=bits2byte(bit);
printf("%d bit/s = %d byte/s", bit, answer);
break;
case 0:printf("\n\nExited Succesfully!");
break;
}
}
int byte2bits(int x)
{
return(x*8);
}
int bits2byte(int x)
{
return(x/8);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter