ok. First off the break is in the wrong place. the switch(ch1) is still part of case 'A' so the break (which tells the computer that case 'A' is now finished) should come afterwards. You were also having the normal problems with scanf(). When you read in ch you actually press 'A' followed by return. The scanf picks up the 'A' but leaves the return in the input buffer. When the next scanf comes along it reads the return character without waiting for the user to enter a value. There are a number of ways to fix this mentioned in the FAQs. I've added a bit of a rough and ready fgets() code to make the code work. You might want to add some error checking.
Code:
#include <stdio.h>
int main() /* main() should return an int */
{
char ch;
char ch1;
char buf[BUFSIZ];
float eur=0.0;
float ster=0.0;
printf("Choose a country for currency conversion\n");
printf ("A.Britain\nB.Denmark\nC.Japan\nD.USA\nE.Exit\n");
fgets(buf, sizeof(buf), stdin); /* safe way to read input from user - need to add error checking */
ch = buf[0]; /* we are only interested in the first character of the input string */
switch (ch)
{
case 'a' :
case 'A' :
printf("Do you wish to convert:\n");
printf("1.From Euro to Sterling\n2.From Sterling to Euro\n");
fgets(buf, sizeof(buf), stdin);
ch1 = buf[0];
switch (ch1)
{
case '1' :
printf("Enter amount in Euro\n");
fgets(buf, sizeof(buf), stdin);
sscanf(buf, "%f", &eur);
ster=eur*0.70;
printf("The equivalent in Sterling is %4.2f\n", ster);
break;
case '2' :
printf("Enter amount in Sterling\n");
fgets(buf, sizeof(buf), stdin);
sscanf(buf, "%f", &ster);
eur=ster*1.42;
printf("The equivalent in Euro is %4.2f\n", eur);
break;
default:
printf("invalid entry");
break;
}
break; /* end of case 'A' and case 'a' */
case 'b' :
case 'B' :
printf("...");
break;
default :
printf("invalid entry");
break;
}
return 0; /* main() should return 0 if successful */
}
enjoy!
edit:: beaten by salem