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); 
}

simple..just declare it..you know how to do that..rite mates..

simple..just declare it..you know how to do that..rite mates..

as i said if i declare it in main function as float, i get value 0

yeah right..
total is currency rite..
try this mates..

float total = 0.0f;
...
total = currency (amount,from,to); 	
system("CLS"); 	
printf("Your currency conversion is: %0.2f\n", total);	
Sleep(1500);
...

yeah right..
total is currency rite..
try this mates..

float total = 0.0f;
...
total = currency (amount,from,to); 	
system("CLS"); 	
printf("Your currency conversion is: %0.2f\n", total);	
Sleep(1500);
...

thank you very much
total = currency (amount,from,to);
that was missed, and i defined total as float inside my function

alright..

hi guys, i'm new in c++ programming

Do you realize that the program you've posted has nothing to do with C++? It's C.

Do you realize that the program you've posted has nothing to do with C++? It's C.

yeah sorry my bad, you think i get flamed now? :P

yeah sorry my bad, you think i get flamed now? :P

Nope. Moved to C-forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.