1. Write a C program that uses structures to store information regarding mobile phones available at a store. You are required to define appropriate data members in order to describe at-least five relevant attributes (e.g. make, screen-size) of the phone. Your program should use functions to:
Allow the end user to add information of a phone (take care of overflow condition).
Filter and display phones with a specific screen size (screen-size would be one of the attributes of the phone structure).
2. (Please refer to https://www.mathsisfun.com/polar-cartesian-coordinates.html for background information required for this problem). Write a C program to maintain data in a union ADT, providing choices for storing a point in cartesian or polar coordinates. The program should have menu options to
Accept data in any format (C / P): e.g. if user enters C store the point in cartesian coordinates
Display the current storage (C / P): Given an instance of point, determine if the storage is Cartesian or polar
Convert the storage format (C->P / P->C): Convert Cartesian coordinates to polar and vice- versa
3. Write a C function that accepts two strings as parameters and returns the concatenated string. The memory block for the returned string should be created dynamically to be large enough to hold the concatenated result. Make sure that the block is valid after the function returns.
Write a main function that concatenates all the strings contained in a two dimensional array, by passing two strings to the function at a time. The main function should then print the final string. So, if the string array is set to {"a ", collection , of , words}, resultant string should be a collection of words. Make sure there are no memory leaks in your code.
4. Create a class to represent a Product with productId, productName, category, stockLevel and unitPrice as attributes. The attributes must be private.
Add appropriate get / set methods to satisfy the following constraints:
Product ID, name and category can't be changed after creation.
Stock Level is changed only when a product is sold or purchased.
All the attributes are readable
The class should have capability to create objects based on parameters passed to constructor. The objects may be created:
either by specifying values for all the attributes
or by leaving out initial value for Stock Level (default value of stock level should be 100, if not specified explicitly).
Add methods to sell and to purchase a product.
Method sellProduct reduced the stock level by the amount sold. It should check for current stock level before processing a sale request. Since a sale request may fail in case requisite stock is not available, the method should return failure status to the calling function.
Methods sellProduct and purchaseProduct should ensure that the units to be sold or purchased are not negative
Test the class by maintaining an array of Products, and generate a tabular report listing all the products sorted on their categories.
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.