Knowee
Questions
Features
Study Tools

Create a structure named warehouse with details like location, name, total_stock_rooms, occupied_rooms, and price_room. Write a C program to input details for the N warehouse. Write user-defined functions for: Function 1: Reading the details of the warehouse. This function should return the structure to the main() function. Function 2: Find the available rooms in the warehouse. Calculate the total cost for available rooms and display the details. Pass the structure returned from function 1 to function 2. Read the number of warehouses, location, name, total_stock_rooms, occupied_rooms, and price_room. Sample Input 2 Chennai Wheat warehouse 100 80 5000 Mumbai Electronic warehouse 15 10 10000 Sample Output [Wheat warehouse in Chennai: Available rooms-20: Cost 100000] [Electronic warehouse in Mumbai: Available rooms-5: Cost 50000]

Question

Create a structure named warehouse with details like location, name, total_stock_rooms, occupied_rooms, and price_room. Write a C program to input details for the N warehouse. Write user-defined functions for: Function 1: Reading the details of the warehouse. This function should return the structure to the main() function. Function 2: Find the available rooms in the warehouse. Calculate the total cost for available rooms and display the details. Pass the structure returned from function 1 to function 2. Read the number of warehouses, location, name, total_stock_rooms, occupied_rooms, and price_room. Sample Input 2 Chennai Wheat warehouse 100 80 5000 Mumbai Electronic warehouse 15 10 10000 Sample Output [Wheat warehouse in Chennai: Available rooms-20: Cost 100000] [Electronic warehouse in Mumbai: Available rooms-5: Cost 50000]

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a C program that follows the instructions given:

#include <stdio.h>

typedef struct {
    char location[50];
    char name[50];
    int total_stock_rooms;
    int occupied_rooms;
    int price_room;
} Warehouse;

Warehouse readWarehouseDetails() {
    Warehouse w;
    printf("Enter location: ");
    scanf("%s", w.location);
    printf("Enter name: ");
    scanf("%s", w.name);
    printf("Enter total stock rooms: ");
    scanf("%d", &w.total_stock_rooms);
    printf("Enter occupied rooms: ");
    scanf("%d", &w.occupied_rooms);
    printf("Enter price per room: ");
    scanf("%d", &w.price_room);
    return w;
}

void calculateAvailableRooms(Warehouse w) {
    int available_rooms = w.total_stock_rooms - w.occupied_rooms;
    int total_cost = available_rooms * w.price_room;
    printf("[%s in %s: Available rooms-%d: Cost %d]\n", w.name, w.location, available_rooms, total_cost);
}

int main() {
    int N;
    printf("Enter the number of warehouses: ");
    scanf("%d", &N);
    Warehouse warehouses[N];
    for (int i = 0; i < N; i++) {
        printf("Enter details for warehouse %d:\n", i+1);
        warehouses[i] = readWarehouseDetails();
    }
    for (int i = 0; i < N; i++) {
        calculateAvailableRooms(warehouses[i]);
    }
    return 0;
}

This program first defines a structure Warehouse to hold the details of a warehouse. It then defines a function readWarehouseDetails to read the details of a warehouse from the user, and a function calculateAvailableRooms to calculate and display the number of available rooms and the total cost for those rooms in a given warehouse.

In the main function, it first asks the user for the number of warehouses, then uses a loop to read the details for each warehouse and store them in an array. Finally, it uses another loop to calculate and display the available rooms and total cost for each warehouse.

This problem has been solved

Similar Questions

Declare a structure named “Furniture” to store details like furniture name, furniture type, cost per unit, length, breadth, height, and color.  You must read the details of N Furniture.  Pass this structure to a user-defined function that will print the details of furniture for the given furniture type.Sample Input2  (N- number of furniture)Chair (furniture name)P  (furniture type . W – wood, P-plastic)500 (cost per unit)100.5( float value for length)56.3( float value for breadth)60.2( float value for heigth)red (color)TableW300060.546.380.4WhiteP  (Enter the furniture type to search) Sample OutputChair500100.556.360.2red

A local painting company calculates the cost of painting rooms based on the size ofthe room. Each square meter of wall space requires a specific amount of paint andlabor, which has a set cost. The company often deals with orders for multiple roomsof different sizes but wants to understand the calculation of total costs to providequick estimates to customers.You are developing a program to help the painting company calculate the total costof painting multiple rooms in a house. You should write a function in pseudocode thataccepts three input parameters: (a) the number of square meters of the room and (b)the number of rooms to paint. The company charges $1.50 per square meter forlabor and paint. The function should return the total cost for painting the rooms.i. Write the function here…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………[3]ii. Use the function defined in part (i) to get the total cost for painting 8 rooms of30 square meters per room. Print the result.……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………[2]

Create a class Building with data members building number, name, area (in square feet), cost/square feet, location, total cost, and year of construction. Declare the cost/square feet as the static data member. Define a parametric constructor to initialize the data members. Make use of this pointer. Create an array of objects and display details of N buildings along with the total cost

Create an array of objects and display details of N buildings along with the total cost

Create a structure named Book for storing book details such as title, author, edition, and price. Write a C program to input details for n books, find the highest expensive and the lowest priced books, and display their information.xxxaaaa1245yyyddd5100xxx aaaa 1 245

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.