I am a new member here and a student in C programming. I had to create a program that, at this point< displays currency conversions. I wanted to add an option in the display, using IF, that would make the output grammatically correct.
For our class, we use Miracle C compiler. When I ran into errors in Miracle C, I tried the code in Visual Studio C++ 2005. In VS it runs fine, but is Miracle C I get the following error;
Miracle C Compiler (r3.2), written by bts.
Compiling c:\documents and settings\steve\my documents\week3_sh\week3_sh.c
main
c:\documents and settings\steve\my documents\week3_sh\week3_sh.c: line 35: unrecognised types in comparison
'if (pesos<1) { printf("Each Mexican Peso is worth %.2f cents in US Dollars.\n\n",pesos)'
aborting compile
Why would this code work in one program and not there other and what am I missing?
Here is the code I have written;
Code:
/*This program is the basis for a currency converter
It's function at this point is to display the title and conversions only.*/
/*
Steve Hohman
POS 370 Programming Concepts
May 30,2005
*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
//Define variables
double pesos;
double euros;
double yen;
double cana;
double uk;
//Define the foreign currency values as floating point numbers
//Convert foriegn currency to 1 US Dollar
pesos=1/.0920090; //Convert the Mexican Peso to US Dollars
euros=1/1.24675; //Convert the Euro to US Dollars
yen=1/.00926255; //Convert the Japanese Yen to US Dollars
cana=1/.796395; //Convert the Canadian Dollar to US Dollars
uk=1/1.82250; //Convert the United Kingdom Pound to US Dollars
/*Display the listing of values to the screen. The purpose of the IF statement
is for proper display should the currency conversion changes above or below one US Dollar*/
//Mexican Pesos
if (pesos<1)
{
printf("Each Mexican Peso is worth %.2f cents in US Dollars.\n\n",pesos);
}
if (pesos>1)
{
printf("Each Mexican Peso is worth $%.2f in US Dollars.\n\n",pesos);
}
//Euros
if (euros<1)
{
printf("Each Euro is worth %.2f cents in US Dollars.\n\n",euros);
}
if (euros>1)
{
printf("Each Euro is worth $%.2f in US Dollars.\n\n",euros);
}
//Japanese Yen
if (yen<1)
{
printf("Each Japanese Yen is worth %.2f cents in US Dollars.\n\n",yen);
}
if (yen>1)
{
printf("Each Japanese Yen is worth $%.2f in US Dollars.\n\n",yen);
}
//Canadian Dollars
if (cana<1)
{
printf("Each Canadian Dollar is worth %.2f cents in US Dollars.\n\n",cana);
}
if (cana>1)
{
printf("Each Canadian Dollar is worth $%.2f in US Dollars.\n\n",cana);
}
//British Pounds
if (uk<1)
{
printf("Each British Pound is worth %.2f cents in US Dollars.\n\n",uk);
}
if (uk>1)
{
printf("Each British Pound is worth $%.2f in US Dollars.\n\n",uk);
}
puts("Press the <ENTER> key to end this program...");
getchar(); //Wait for <ENTER> key
return 0;
}
Thanks for any help you can offer.
Salty