Das Problem ist das wenn ich für die Variabel x den Wert 100 eingebe und es in US umrechnen lassen möchte also mit der y=xEUtoUS Funktion kommt das Ergebnis 120,000008 raus. Woran liegt das und wie kann ich es vermeiden? Wenn ich statt y=xEUtoUS y=1001.2 funktioniert es ohne Probleme.
#include <stdio.h>main(){ float x = 0; float EUtoUS = 1.2; float EUtoGBP = 0.884; float GBPtoUS = 1.35173; int EU = 1; int US = 2; int GBP = 3; int w; int z; float y; printf("Waehlen Sie die zu wechselnde Waehrung aus\n"); printf(" Euro = 1 \n US-Dollar = 2 \n Britische Pfund = 3 \n"); scanf("%d",&w); printf("Waehlen Sie nun die Ziel Waehrung aus\n"); printf(" Euro = 1 \n US-Dollar = 2 \n Britische Pfund = 3 \n"); scanf("%d",&z); printf("Geben Sie ihren umzurechnenden Wert ein\n"); scanf("%f",&x); if( w == 1) if(z == 2) y=xEUtoUS; else if (z == 3) y=xEUtoGBP; else printf("Bitte Waehlen Sie eine andere Waehrung\n"); printf("Sie erhalten %f\n",y);}