# Thread: 0 failures but does not complile. Does anyone know what is happening?

1. ## 0 failures but does not complile. Does anyone know what is happening?

Hello I wrote a few hours earlier and Ive been working on it. I am trying to write a calculator program the output should be:

2. subtraction
3. multiplicaiton
4. division
5. Exit

please enter two numbers separated by a space: ?
the result of %f and % f is %f.

I've tried for a while. I am not sure about the while loop. Any help woould be very much appreciated! I can't attach the code below so i copied pasted it:

Code:
```#include<stdio.h>
float choice;
float result;
float num1, num2;
int get_choice();
int main()
{
{
float num1, num2;
int choice;
float result;
do
{
printf("Welcome to Colleen Gonzales's Handy Calculator");
printf("2. Subtract\n");
printf("3. Multipilcation\n");
printf("4. Division\n");
printf("5. Exit\n");
scanf("%f", &choice);
}
while( (choice = 1,2,3, 4 , 5) );
printf("Please choose two numbers seperated by a space:");
scanf("%f %f", &num1, &num2);
return 0;
}
{
float num1, num2, result;
int choice;
while( (choice=get_choice()) !=5)
{
switch (choice)
{
case 1 : result = num1 + num2;
break;
case 2 : result = num1-num2;
break;
case 3 : result = num1 * num2;
break;
case 4 : result = num1/num2;
break;
case 5 : printf("Goodbye");
break;
default :printf("Please respond with 1, 2, 3, 4, or 5\n");
break; /*end of switch*/
}
}

printf("The result of %f and %f is %.2f\n", &num1, & num2, &result);
return 0;
}
}
```

2. Code:
`while( (choice = 1,2,3, 4 , 5) );`
You can't do that.
You've just written something that you'd like to be how you could write such a thing, but C does not have such shortcuts for doing what you want in that sort of way. What you want to do is to loop while the number entered is less than 1 or the number entered is greater than 5.

Also, if the user selects 5, then why would you still ask for two numbers?
And if they had entered 1 to 4, then you just terminate the program after getting the input.

As much as you may have intended to do so, you don't actually have a function called get_choice in the code you have posted. All you have is an unused function prototype.

Your best option is copy and paste the code as plain-text, and make sure that the indentation is preserved. It's horrible reading code with no indentation.

Edit: Dammit, why did you start a second thread?! I found your other one after replying to this one.

3. okay sorry ill try to delete this one...i did try to add. But it wasnt letting me.

4. 0 failures but does not complile. Does anyone know what is happening? - Dev Shed
Pick a forum, and pick a thread
If you post all over the place, you'll just ........ everyone off and get confusing mixed messages.

And when you copy/paste code, make sure you "paste as text".