1. ## need urgent help

hey!!!!! i find this very difficuilt please cud you help me write a program that reads numbers from a file and finds the sum, average, maximum and the minimum values.

I got one program here , but i cannot post on this thread because something is wrong with my computer. This question is from a past year test paper and im finding difficuilties in solving this program.........please help.

2. Sure. You need to
3. Keep track of the maximum and the minimum
4. Find the average

Each bit should be separate from all the others and treated as such.

3. Computer problems, eh? How did he manage to post this thread? Copy and paste didn't work? He didn't reel in Tabstop either! No integrity with this poster at all!

4. I got one program here
So... what's your problem, then? We're not gonna write another one for you. Have you tried it yourself? Do you understand how to do it mathematically?

5. I nominate this post for the worst "Please do my homework" post ever.

6. The easiest program after "Hello word"... you should change work :P

7. Code:
```#include <stdio.h>
int main()
{
int c = 1;
while (c)
{
}
}```
Should do the trick

8. Shouldn't be that hard to write such a program, if a minimal amount of effort was spent in studying a good C resource, such as a good book.

tabstop's solution can be made a little less complicated by adding the numbers as they are being read, thereby leaving out the mess of advanced memory management (although mathematical overflow could technically still occur if given input under certain conditions). To calculate the average would only entail keeping track of how many numbers have been read.

9. Well i got one program here but when i compile it there's some errors with it so can you help in identifying some errors pleae.

Code:
```#include<iostream>
#include<stdlib.h>

int main()
{
FILE *file_1;
float average, max, min;
float sum=0; int val;
int count=0;//1
printf("**********This Program reads input from a file and then calculates:************\n\t\t\t the sum,\n\t\t\t average,\n\t\t\t maximunm and \n\t\t\t the minimum values.\n\n");
printf("*******************************************************************************\n");
if ((file_1 = fopen("input.txt","r"))!= NULL)   //1
{
fscanf(file_1, "%d", &val); //1
max= val;
min = val;
sum = val;
count++;
while(!(feof(file_1))) //1
{

}
average = sum/count;
printf("\n\tHere are the results:\n");//1
printf("\t\tThe sum is %lf\n",sum);
printf("\t\tNumber of values is %d\n", count);
printf("\t\tAverage is %lf\n", average);
printf("\t\tMaximum is %lf\n", max);
printf("\t\tMinimum is %lf\n", min);
fclose(file_1);
if ((file_1 = fopen("result.txt", "w"))!= NULL)//1
{
fprintf(file_1,"%s\n","Here are the results:");//1
fprintf(file_1,"%s\t", "The sum is");
//write codes here
fclose(file_1);
}
}
else
printf("Sorry,unable to open input.txt\n");
printf("\t\t\t\t\tProgram Complied by:\n");
printf("\t\t\t\t\t\t\tKaylash (18/05/09)\n\n");
system("pause");
return 0;
}```

10. I'd expect tons of errors if that is a C program, since iostream is a C++ I/O header. Perhaps you meant to include stdio.h

--
Mats

11. Originally Posted by luke luvevou
when i compile it there's some errors with it so can you help in identifying some errors pleae.
The problem is "the cat has got your tongue" (my mom used to say that when I would sulk).

Why don't *you* tell us what the errors are, or make some kind of effort to explain yourself further?

12. Do you know what would really be a good idea? Actually saying what errors you're getting. I've been wanting to post this...

Quzah.

13. Originally Posted by quzah
I've been wanting to post this...

And (wow!) look, that has been translated into "Bahasa Indonesian Brazilo-Portuguese Chinese Czech Danish Dutch Estonian Finnish French Georgian German Greek Hebrew Hungarian Italian Japanese Polish Portuguese Romanian Russian Serbian Spanish Swedish Thai Turkish".

Now I can easily figure out how to say "Try to find an answer by inspection or experimentation" in Estonian, which is something I have always wanted to do.

I think maybe this one would be good in Brazilo-Portuguese:
We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding (often enough to bet on, anyway). Answering questions for careless and sloppy thinkers is not rewarding; we'd rather spend our time elsewhere.

So expressing your question clearly and well is important. If you can't be bothered to do that, we can't be bothered to pay attention.

14. ok i have identify the errors my self after rewriting the program thanks for no help

15. Hahaha, legendary! Good job then.