Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int limit, i ,n, sum=0;
- FILE *fp;
- fp = fopen("C:\\DATA.TXT","w");
- printf("Enter number of elements: ");
- scanf("%d",&limit);
- printf("Enter %d elements:-\n",limit);
- for(i=0;i<limit;i++)
- {
- scanf("%d",&n);
- putw(n,fp);
- }fclose(fp);
- fp=fopen("c:\\Data.txt","r");
- while((n=getw(fp))!=EOF)
- sum+=n;
- printf("Sum = %d",sum);
- fclose(fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement