Advertisement
ABED160105

A_ABED

May 23rd, 2020
1,299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <stdio.h>              /// standard input output header...
  2. #include <math.h>              /// defines various mathematical functions ...
  3. #include <conio.h>            /// console input and output ...
  4. #include<string.h>           /// string handling & various memory handling functions ...
  5. #include <stdlib.h>         /// standard library header ...
  6. #include <windows.h>       /// for all of the functions in the Windows API ...(Application programming interface)
  7. #include<time.h>         /// for device time ...
  8.  
  9.  
  10.  
  11. FILE*fp,*fp1,*fpa; /// *fp- user.txt , *fp1 - temp.txt , fpa - admin.txt ...
  12.  
  13. int u_id;
  14. char u_name[100];
  15. char u_type;
  16. int u_balance;
  17.  
  18. char check_balance(int n)
  19. {
  20.     int count=-1;
  21.     int T_balance=0;
  22.  
  23.     system("cls");
  24.  
  25.     fp=fopen("in.txt","r");   ///data file open to append (add) record
  26.  
  27.     while(fscanf(fp,"%d %s %c %d\n",&u_id,&u_name,&u_type,&u_balance)!=EOF)
  28.     {
  29.         count++;
  30.         if(count==n)
  31.         {
  32.             printf("Total balance = %d\n",T_balance);
  33.             printf("Average balance = %d\n",(T_balance/n));
  34.             break;
  35.         }
  36.  
  37.         T_balance+=u_balance;
  38.  
  39.        /// printf("%d  %s  %c  %d\n",u_id,u_name,u_type,u_balance);
  40.  
  41.     }
  42.  
  43.     fclose(fp);
  44.  
  45. }
  46.  
  47. int main()
  48. {
  49.     int n;
  50.     scanf("%d",&n);
  51.     check_balance(n);
  52.     return 0;
  53. }
  54. ///abed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement