Question

Create a structure to specify data of5 customers in a bank. The data to be stored is: Name, Account number and Balance in account. Write a program that accepts 5 customers data from the user. Once the data has been input, it should be printed using printf function (Hint: A similar example was considered in class to receive data of books)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>

struct Customers{ //structure for customers of bank

char name[50];

int accNo;

float balance;

};

int main(){

struct Customers cust[5]; //5 customers are created

int i;

for(i=0; i<5; i++){

printf("\nEnter data for customer %d", (i+1));

printf("Enter name: ");

scanf("%s", cust[i].name); //input name

printf("Enter acc no: ");

scanf("%d", &cust[i].accNo); //input account number

printf("Enter balance: ");

scanf("%f", &cust[i].balance); //input balance

}

for(i=0; i<5; i++){

printf("\ncustomer %d", (i+1)); //display all details

printf("\n\tName: %s", cust[i].name);

printf("\n\tAcc no: %d", cust[i].accNo);

printf("\n\tBalance: %f", cust[i].balance);

}

return 0;

}

PROGRAM

#include<stdio.h> 4 struct Customerst 5 /structure for customers of bank 7 8 9 char name[50]; int accNo; float balance 10 11 int main)f 12 13 14 15 16 17 18 19 20 21 15 customers are created struct Customers cust[5]; int i; for (i-0; i<5; i++)1 printf(\nEnter data for customer %d, (i+1)); printf(Enter name: ; scant(%s, cust [i].name); printf(Enter acc no: ); scant(%d, &cust [i].accNo); //input account number printf(Enter balance: ); scant(%f, &Cust [1].balance); //input balance //input name 23 24 25 26 27 28 29 30 31 32 printf(Vncustomer%d,(1+1)); //display all printf(\n\tName : %s, cust [i].name); printf(\n\tAcc no: %d, cust [i].accNo); printf(\n\tBalance: %f, cust [i].balance); details return ; 34 L 35 I

Add a comment
Know the answer?
Add Answer to:
Create a structure to specify data of5 customers in a bank. The data to be stored...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a function john, accepts a structure of type employee and return the same structure. Ask...

    Create a function john, accepts a structure of type employee and return the same structure. Ask the user using printf and scanf to enter employee information (name, id and salary). You might use fgets for name, as scanf can not be used for strings with spaces. In main: Declare a structure of type employee Call function john and pass the structure. Display using prinf employee structure information returned from function john.

  • Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment...

    Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...

  • In C++ Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e.,...

    In C++ Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). Create an inheritance hierarchy containing base class Account and derived...

  • Create a program SearchNewBooks.cc that given as command line input newbooks.dat and request.dat and a method...

    Create a program SearchNewBooks.cc that given as command line input newbooks.dat and request.dat and a method of search either binary or linear, creates a file of the number of books found from the request list. program should receive two filenames as command line arguments, the new books file and request file, which the program should read in. The list of new books and list of requested books should should be stored in only two ​std::vector​ containers. Because some code to...

  • Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

    Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for...

  • *** C++ *** Create a class called Student that contains a first name ( string) and...

    *** C++ *** Create a class called Student that contains a first name ( string) and an student id number (type long).     1. Include a member function called get_data( ) to get data from the user for insertion into the object,     2. Also include a function called display_data( ) that displays the student data. Then write a complete program that uses the class to do some computation. Your main function, main( ), should create a Dynamic Array of...

  • Create the program in C++ please. The new operator as outlined in 10.9 . Create a...

    Create the program in C++ please. The new operator as outlined in 10.9 . Create a Test class that includes the following Data members • First Name, last name, test1, test2, test3 o Methods • Accessor methods for each of the data members' • Mutator methods for each of the data members . A Default Constructor . A constructor that will accept arguments for each of the 5 data members • A method that will calculate the average of the...

  • Write a program that keeps track of a speakers’ bureau. The program should use a structure...

    Write a program that keeps track of a speakers’ bureau. The program should use a structure to store the following data about a speaker: (this is in C++) Name Telephone Number Speaking Topic Fee Required The program should use a vector of structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the vector. The program should have a menu-driven user interface. Input Validation: When the...

  • Java Data Structures

    Programming Instructions:Using      Java Object Oriented Principles, write a program which produces the      code as indicated in the following specifications: Your       program must be a console application that provides a user this exact       menu:Please select one of the following:1: Add Client to Bank2: Display Clients in the Bank3: Set Bank Name4: Search for a Client5: Exit Enter your Selection: <keyboard input here> The       menu must be displayed repeatedly until 5...

  • Write a Python program to create userids: You work for a small company that keeps the...

    Write a Python program to create userids: You work for a small company that keeps the following information about its clients: • first name • last name • a user code assigned by your company. The information is stored in a file clients.txt with the information for each client on one line (last name first), with commas between the parts. In the clients.txt file is: Jones, Sally,00345 Lin,Nenya,00548 Fule,A,00000 Your job is to create a program assign usernames for a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT