I'm getting an error which I am not able to resolve. I've gone through my code thoroughly with no success. What am I doing wrong? See code below.
Compiler error:
In function 'main':
ou1.c:49:1: error: expected 'while' before 'printf'
printf("End of program!
");
^
My code:
#include <stdio.h>
int main(void){
int choice;
float price, sum, SUMusd;
float rate =1;
printf("Your shopping assistant");
do{
printf("1. Set exchange rate in usd (currency rate:%f)
", rate);
printf("2. Read prices in the foreign currency
");
printf("3. End
");
printf("
");
scanf("%d", &choice);
switch(choice){
case 1:
printf("Give exchange rate:
");
scanf("%f", &rate);
break;
case 2:
do{
printf("Give price(finsh with < 0)
");
scanf("%f", &price);
sum =+ price;
}while(price <= 0);
SUMusd = sum*rate;
printf("Sum in foreign currency: %f", sum);
printf("Sum in USD:%f", SUMusd);
break;
default:
printf("Invalid choice
");
break;
}while(choice != 3);
}
printf("End of program!
");
return 0;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…