Member Avatar for Bassel_1

Hi guys. I want your help to convert this program from c++ to c language

The question is :-A manufacturer wishes to determine the cost of producing an open-top cylindrical
container. The surface area (of the container is the sum of the area of
the circular base plus the area of the outside (πr2
+2πrh).
Write a program to read the radius of the base r, the height of the container h, the
cost per square centimeter of the material (cost) and the number of containers to be
produced (Quantity) from the user. You should calculate the cost of each container
and the total cost of producing all the containers and print the results on screen.

#include using namespace std; int main() double radius; double height; double cost; int nContainers; double SA; double costContainer; double costAll; float pi = 3.14159265; cout << "Enter the radius of the base (in inches): "; cin >> radius; cout << "Enter the height of the container (in inches): "; cin >> height; cout << "Enter the cost of each container per square centimeter: $"; cin >> cost; cout << "Enter the number of containers to be produced: "; cin >> nContainers; double Radius = radius 2.54; double Height = height 2.54; SA = pi Radius Radius + 2 pi Radius Height; costContainer = SA cost; costAll = costContainer * nContainers; cout << nContainers << " container(s) at $" << cost << " per square centimeter will cost $" << costContainer << " each." << endl; cout << "The grand total for " << nContainers << " containers is $" << costAll << "." << endl; return 0;

If I had to do such I take it line by line. I'll start with line 1. That would be commented out as I don't know what includes or libraries I need yet.

You can work the next line then the next until done. Even badly formatted this looks like something a first year C programmer should be able to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.