upsidedown

Files

Aug 2nd, 2011
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. /*read 3 nod frm file and output som to other file*/
  2.  
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5.  
  6.  
  7. main()
  8. {
  9.     int i,no,sum=0;
  10.     FILE *f1,*f2;
  11. //  char abcd[50];
  12.     f1=fopen("in.txt","r");
  13.     f2=fopen("out.txt","w");
  14.  
  15.     for(i=0;i<5;i++)
  16.     {
  17.         fscanf(f1,"%d",&no);
  18.         sum+=no;
  19.     }
  20.  
  21.     printf("\nthe sum is %d",sum);
  22.  
  23.     fprintf(f2,"the sum is %d",sum);
  24.     printf("\noutput written to file out.txt\n");
  25.     fclose(f1);
  26.     fclose(f2);
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment