Beruflich Dokumente
Kultur Dokumente
Structures & Files 1. Create a structure to specify data of customers in a bank. The data to be stored is: Account no, Name and balance in the account. a) Write a function to print the account number and name of each customer whose balance below Rs 2000 b) Write a function to accept the account no and amount from the customer and perform a withdrawal or deposit and print the customer information along with the new balance.
2. Create a structure employee that holds information like employee code, name, and date of joining and salary of employees. Write a program to create array of structures and enter data to it. Pass the array to a function and return the employee information highest paid employee. (Pass array of structures to function and return structure)
3.
Write a function to accept n students record and to return the records of a student with highest CGPA. Each record has the name, regno, branch and and CGPA as fields. (Pass array of structures to function and return a record)
4. Write a program to read employee records from a file using structures and display on the screen. Also display the total count of characters, spaces and numbers in the file.
5.
Write a program to append the contents of one text file at the end of another. Answer the following questions.
Suppose this program were executed using the command: gcc mult.c o mul a. usage: ./mul 0 0 b. usage: ./mul 10 20 30 c. usage: ./mul x y z d. usage: ./mul 9.3 8.2 7.6 Find the output for each of the following cases for the given program?
Modify the above program to find the product of n nos. 7. Show the output and answer the questions for the following program. // start of structure definition struct Song { char Name[25]; float Length; }; // end of structure definition
// function prototype, receives and returns structure data type struct Song ZeroOut(struct Song);
// beginning of function definition struct Song ZeroOut(struct Song x) { struct Song y = {"Have Mercy On Me", 3.20F}; strcpy_s(x.Name, 25, " "); x.Length = 0; return y; } // end of function definition a) The structure is not defined inside any function. If it were defined inside the main() function, as was done in the previous exercises, will this program work? Why or why not? b) As shown in the program, the definition of the structure is global, that is, it is available to all functions. Title1 in main() becomes what variable in ZeroOut()?
8. Here is the declaration for struct contract; union aptinfo holds information pertinent to renting, leasing or purchasing an apartment, in that order. The member how_held, which can have values RENT, LEASE or PURCHASE, determines which alternative is active. #define RENT 1 #define LEASE 2 #define PURCHASE 3 struct leaseinfo{ double monthly_lease; int lease_period;