Created
April 30, 2017 14:06
-
-
Save bykalim/756d219f5ec5997d10302899841d7137 to your computer and use it in GitHub Desktop.
CA Programming Lab3: at RUPP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Written 25/4/2017 | |
// By Kalim | |
// V1 | |
#include <stdio.h> | |
int Hex = 0; | |
int Dec = 0; | |
void H2D(){ | |
printf("+---------------------------------+\n"); | |
printf("| Hexdecimal to Decimal |\n"); | |
printf("+---------------------------------+\n"); | |
printf("1. Please input an Hexdecimal number\n"); | |
scanf("%x", &Hex); | |
printf("%d\n", Hex); | |
}; | |
void D2H() { | |
printf("+---------------------------------+\n"); | |
printf("| Decimal to Hexdecimal |\n"); | |
printf("+---------------------------------+\n"); | |
printf("1. Please input an Decimal number\n"); | |
scanf("%d", &Dec); | |
printf("%x\n", Dec); | |
} | |
int main(int argc, char const *argv[]) { | |
int choice; | |
printf("+-------------------------------------------------+\n"); | |
printf("| Hexdecimal <----> Decimal |\n"); | |
printf("+-------------------------------------------------+\n"); | |
printf("| 1. Hexdecimal to Decimal Converter |\n"); | |
printf("| 2. Decimal to Hexdecimal Converter |\n"); | |
printf("+-------------------------------------------------+\n"); | |
scanf("%d", &choice); | |
switch (choice) { | |
case 1: H2D(); | |
break; | |
case 2: D2H(); | |
break; | |
default: | |
break; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment