Posts

Showing posts with the label Exchange

In C, Convert Currency Values

Image
  #include<stdio.h> #include<string.h> void main(){ char from_text[10]; char into_text[10]; float from_value = 0.0f; float into_value = 0.0f; int from_currency = 0; int into_currency = 0; printf("Input currency value to convert: "); fflush(stdin); scanf("%f", &from_value); printf("Enter 1 if converting from Dollars or 2 if converting from Euros\nChoice: "); fflush(stdin); scanf("%d", &from_currency); switch(from_currency){ case 1: strcpy(from_text, "dollars"); break; case 2: strcpy(from_text, "euros"); break; default: printf("Invalid source currency!!\n"); return; } printf("Converting to: 1 (Euros)\n"); printf("Converting to: 2 (Dollars)\n"); printf("Converting to: 3 (Yen)\n"); printf("Converting to: 4 (Pounds)\nChoice: "); fflush(stdin); scanf("%d", &into_currency); into_value = from_value;...