Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- b) Write a structure to store the name, account number and balance of
- Customers (more than 10) and store their information.
- i) Write a function to print the names of all the customers having balance
- less than $200.
- ii) Write a function to add $100 in the balance of all the customers having
- more than $1000 in their balance and then print the incremented value of
- their balance.
- */
- #include<stdio.h>
- #include <stdlib.h>
- #define MAX 15
- /* Defining Structre*/
- struct bank
- {
- char name[20];
- int acc_no;
- int bal;
- };
- /*Function to find the details of customer whose balance < 100.*/
- void check(struct bank b[],int n) /*Passing Array of structure to function*/
- {
- int i;
- printf("\nCustomer Names whose Balance < $200\n");
- printf("----------------------------------------------\n");
- for(i=0;i<n;i++)
- {
- if(b[i].bal<200)
- {
- //printf("Account Number : %d\n",b[i].acc_no);
- printf("Name : %s\n",b[i].name);
- //printf("Balance : %d\n",b[i].bal);
- printf("------------------------------\n");
- }
- }
- }
- void addHundred(struct bank b[],int n) /*Passing Array of structure to function*/
- {
- int i;
- printf("\nCustomer Details whose Balance > $1000 after adding $100\n");
- printf("----------------------------------------------\n");
- for(i=0;i<n;i++)
- {
- if(b[i].bal>1000)
- {
- //printf("Account Number : %d\n",b[i].acc_no);
- b[i].bal += 100;
- printf("Name : %s\n",b[i].name);
- printf("Balance : %d\n",b[i].bal);
- printf("------------------------------\n");
- }
- }
- }
- int main()
- {
- struct bank b[MAX];
- printf("Enter number of customers: ");
- int n;
- scanf("%d", &n);
- int i;
- for(i=0;i<n;i++)
- {
- printf("Enter Details of Customer %d\n",i+1);
- printf("------------------------------\n");
- printf("Enter Account Number : ");
- scanf("%d",&b[i].acc_no);
- printf("Enter Name : ");
- scanf("%s",b[i].name);
- printf("Enter Balance : ");
- scanf("%d",&b[i].bal);
- printf("------------------------------\n");
- }
- check(b,n); //call function check
- addHundred(b, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement