# Thread: how to do this currency conversion

1. ## how to do this currency conversion

hello gents
I am a beginner for the last 15 years as I do little bit of programming for a month and then give up on C-programming
Here is my homework and is little frustrating for my ignorance and asking too..
I need to in this code below..
If curr(currency) selection is if 0>curr<6 then printf("error: please enter between 1 to 5 for selection and then proceed with calculation of currency conversion\n")

How do I do this as when I enter 6(not acceptable) it proceeds to switch/case
part(why?)
but it should only proceed to switch/csae till the input(curr) is between 1 to 5
HOW ?? can someone read my code and see what can be done

Code is attached with some explanations too in the code

2. You could put the entry for curr inside a do while loop:

Code:
```  do {
printf("Please Enter 1 to 5 for the Above World Currency \n"    );
/*printf("you want the : \n");*/
scanf("%d", &curr);
getchar();
}while((curr < 1) || (curr > 5));```

3. This code would done your stuff using switch case
Code:
```#include<stdio.h>
int main()
{
int a ;

while(1)
{
scanf("%d",&a);
switch(a>0&&a<6)
{
case 0:
printf("Please enter a valid number \n");
break ;
default :
break ;
}}
}```
The main thing is we cannot write a conditional statement in the case we must give the
integer constant only.