the program should compute the sum of all the interger between m and n that are divisible by k
2006-10-18
05:32:12
·
4 answers
·
asked by
help
1
in
Computers & Internet
➔ Programming & Design
/*Write an interactive program that asks the user to supply three integers'
k,m,n with k being >than 1. Write a program that computes the sum of all the
intergers between m and n that is divisble by k.*/
#include
main()
{
int i, k, m, n, e,sum,total,then;
FILE *inf,*outf;
inf = fopen("data3.dat","r");
outf = fopen("data3out.txt","w");
e=fscanf(inf,"%d %d %d",&k,&n,&m);
fprintf (outf,"Output:\n\n k, m, n\n\n");
fprintf(outf," %d %d %d\n\n",k,m,n);
fprintf(outf,"\nSORRY: end of file - bye!\n\n");
while (e==1)
{
} sum=0;
for (int i=0;i<=n,i++)
then ;
if ((i%k)==0)
sum =sum +i;
e=fscanf(inf,"%d %d %d",&k,&n,&m);
}
}
when I make the changes it still dose not work . It not reading the input file at all.
2006-10-19
09:56:41 ·
update #1