Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h> /// standard input output header...
- #include <math.h> /// defines various mathematical functions ...
- #include <conio.h> /// console input and output ...
- #include<string.h> /// string handling & various memory handling functions ...
- #include <stdlib.h> /// standard library header ...
- #include <windows.h> /// for all of the functions in the Windows API ...(Application programming interface)
- #include<time.h> /// for device time ...
- FILE*fp,*fp1,*fpa; /// *fp- user.txt , *fp1 - temp.txt , fpa - admin.txt ...
- int u_id;
- char u_name[100];
- char u_type;
- int u_balance;
- char check_balance(int n)
- {
- int count=-1;
- int T_balance=0;
- system("cls");
- fp=fopen("in.txt","r"); ///data file open to append (add) record
- while(fscanf(fp,"%d %s %c %d\n",&u_id,&u_name,&u_type,&u_balance)!=EOF)
- {
- count++;
- if(count==n)
- {
- printf("Total balance = %d\n",T_balance);
- printf("Average balance = %d\n",(T_balance/n));
- break;
- }
- T_balance+=u_balance;
- /// printf("%d %s %c %d\n",u_id,u_name,u_type,u_balance);
- }
- fclose(fp);
- }
- int main()
- {
- int n;
- scanf("%d",&n);
- check_balance(n);
- return 0;
- }
- ///abed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement