# Thread: End of user input must be 999

1. Originally Posted by Spidey
Well, I'm assuming you've got the first part done since your posting it.
So, That means that you are reading in input and storing it somewhere right ?
So, all you have to do is think of a way to not read in more data if the user entered 999.
Try writing it in english and then work your way into code.

heres a simple example -

Check the input.
If it is not 999, store it.
otherwise
.
should i use "if... else....." to solve it?

2. should i use "if... else....." to solve it?
Well, there are a number of ways you could solve this problem.
My point was not to take it what I wrote as a direct translation, but to think about the problem and how you would solve it.

If you believe you could do it using an if..else statements then go ahead and try it out and see what you come up with. After that think of ways to improve your program or how you could write it using a different approach.

The best way to learn programing is by actually doing it, and I'm sure you've heard this/will hear this a lot of times.
So write some code and see where you get with it.

3. The very basic fundamentals for a programmer is to be able to code logic! This usually means that the programmer can translate flow charts and pseudo code into real code.
This is a part we cannot help you with! This is the part that YOU must fully understand in order to program any sort of program.
But it's not difficult. All that is required is that you think about how something is done and that you know about these control statements in the language.
Do you know about loops and if statements? They control the logic of the program.

4. thanks guys.. i'd try already.. but, got some errors...
can u guys help me.. just state wut is wrong..
i'll try to figure out myself, coz i wanna learn it.. =)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code:
```#include <stdio.h>
int main ()
{
float average, fahrenheit, Celcius, total;
int counter;

total = 0;
counter = 0;

do {
printf("Enter temperature readings in Fahrenheit (999 to end): ");
scanf("%f", &fahrenheit);
counter = counter + 1;
Celcius = (fahrenheit-32) * 5/9;
printf("\n%d.Fahrenheit\tCelsius\n", counter);
printf("%.2f\t\t%.2f\n\n", fahrenheit, Celcius);
}while (fahrenheit != 999);

if (counter != 0) {
total = total + Celcius;
average = total / counter;
printf("Average is %.2f Celcius\n", average);
}
else

return 0;
}```
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
i want the output to be like this:

Enter temperature readings in Fahrenheit (999 to end): 88 77 80 999
1. Fahrenheit-------Celcius
88-------------------30.89
2.Fahrenheit--------Celcius \*please ignore "-----------" i just want to make the output*\
77--------------------24.77
3.Fahrenheit--------Celcius
80--------------------26.67

Average 41.65 Celcius

5. ## got it!!!

Code:
```#include <stdio.h>
int main ()
{
float average, fahrenheit, Celcius, total;
int counter;

total = 0;
counter = 0;

printf("Enter temperature readings in Fahrenheit (999 to end): ");
scanf("%f", &fahrenheit);
while (fahrenheit != 999)
{
Celcius = (fahrenheit-32) * 5/9;
total = total + Celcius;

counter = counter + 1;
printf("\n%d.Fahrenheit\tCelsius\n", counter);
printf("%.2f\t\t%.2f\n\n", fahrenheit, Celcius);

scanf("%f", &fahrenheit);
}

if (counter != 0) {
average = total / counter;
printf("Average is %.2f Celcius\n", average);
}
else

return 0;
}```
but, my 'else" isnt workin...
how can i fix it?

6. In what way does it not work?

7. Originally Posted by tabstop
In what way does it not work?
ok~
the program should exit to else statement if i enter the input without 999..
but it doesnt go to else statement....

Code:
```Enter temperature readings in Fahrenheit (999 to end): 77

1.Fahrenheit    Celsius
77.00           25.00```

8. You have no if, let alone an else, inside your while loop.

9. Originally Posted by tabstop
You have no if, let alone an else, inside your while loop.
ah ha!! got it tabstop!! gee~ thanks!