Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*read 3 nod frm file and output som to other file*/
- #include<stdio.h>
- #include<stdlib.h>
- main()
- {
- int i,no,sum=0;
- FILE *f1,*f2;
- // char abcd[50];
- f1=fopen("in.txt","r");
- f2=fopen("out.txt","w");
- for(i=0;i<5;i++)
- {
- fscanf(f1,"%d",&no);
- sum+=no;
- }
- printf("\nthe sum is %d",sum);
- fprintf(f2,"the sum is %d",sum);
- printf("\noutput written to file out.txt\n");
- fclose(f1);
- fclose(f2);
- }
Advertisement
Add Comment
Please, Sign In to add comment