Advertisement
silentkiler029

shariar-friend's call-structure

May 18th, 2020
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define debug 00
  5.  
  6. typedef struct {
  7.     char name[80];
  8.     char account_no[9];
  9.     double balance;
  10. }BankAccount;
  11.  
  12. void lowestBalance(BankAccount ara[], int size)
  13. {
  14.     int i, id = 0;
  15.     double lowest = ara[0].balance;
  16.     for(i = 0; i < size; i++){
  17.         if(ara[i].balance < lowest){
  18.             lowest = ara[i].balance;
  19.             id = i;
  20.         }
  21.     }
  22.     printf("id: %s\tlowest balance: %0.2lf\n", ara[id].account_no, lowest);
  23. }
  24.  
  25. int main()
  26. {
  27.     int n = 3;
  28.     BankAccount ara[n];
  29.  
  30.     int i;
  31.     for(i = 0; i < n; i++){
  32.         printf("Enter name: ");
  33.         scanf(" %[^\n]", ara[i].name);
  34.  
  35.         printf("Enter account no (8 digit without space): ");
  36.         scanf("%s", ara[i].account_no);
  37.         ara[i].account_no[9] = '\0';
  38.  
  39.         printf("Enter balance: ");
  40.         scanf("%lf", &ara[i].balance);
  41.     }
  42.  
  43.     if(debug) for(i = 0; i < n; i++){
  44.         printf("Name: %s\nAccount No: %s\nBalance: %0.2lf\n", ara[i].name, ara[i].account_no, ara[i].balance);
  45.     }
  46.  
  47.     printf("Enter your 8 digit account number to search for balance: ");
  48.  
  49.     char account_number[9];
  50.     int flag = 1;
  51.     scanf("%s", account_number);
  52.     account_number[8] = '\0';
  53.  
  54.     for(i = 0; i < n; i++){
  55.         if(strcmp(account_number, ara[i].account_no) == 0){
  56.             printf("%Your account balance is %0.2lf BDT\n", ara[i].balance);
  57.             flag = 0;
  58.             break;
  59.         }
  60.     }
  61.  
  62.     if(flag) printf("Account Not Found\n");
  63.  
  64.     lowestBalance(ara, n);
  65.  
  66.  
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement