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;
}