hi guys, i'm new in c++ programming in this forum too, seen many helpful threads so far, but i just can't get over this one, something wrong with my return value , it says so "total" is undeclared identifier (line 46), but when i declare it in main function as float it returns value 0 :(
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
float currency (float amount,int from,int to);
int main ()
{
float amount;
int from,to,again;
menu:
printf("Convert From:\n1.EUR 2.GBP 3.USD\n");
scanf("%d",&from);
if(from>3||from<0)
{
printf("Error - please sellect menu 1-3\n");
Sleep(1400);
system ("CLS");
goto menu;
}
system ("CLS");
menu2:
printf("Convert To:\n1.EUR 2.GBP 3.USD\n");
scanf("%d",&to);
if(to>3||to<0)
{
printf("Error - please sellect menu 1-3\n");
Sleep(1400);
system ("CLS");
goto menu2;
}
if (from==1&&to==1||from==2&&to==2||from==3&&to==3)
{
printf("Error - you sellected the same currency twice\n");
Sleep(1400);
system ("CLS");
goto menu;
}
system("CLS");
printf("Please Enter the monetary value to covnert:\n");
scanf("%f",& amount);
{
currency (amount,from,to);
system("CLS");
printf("Your currency conversion is: %0.2f\n", total);
Sleep(1500);
}
system("CLS");
printf("press '1' to start over,or any key-to exit program\n");
scanf("%d",&again);
if(again==1)
{
system("CLS");
goto menu;
}
else
return(0);
}
float currency (float amount,int from,int to)
{
float total;
if (from==1&&to==2)
{
total=amount*0.91;
}
if (from==2&&to==1)
{
total=amount*1.09;
}
if (from==1&&to==3)
{
total=amount*1.5;
}
if (from==3&&to==1)
{
total=amount*0.66;
}
if (from==2&&to==3)
{
total=amount*1.64;
}
if (from==3&&to==2)
{
total=amount*0.6;
}
return(total);
}