Question

2. Write a program which defines a (hollow rectangular) prism as a structure consisting of: length(int) width(int) height(int

Write a C Program

0 0
Add a comment Improve this question Transcribed image text
Answer #1


#include <stdio.h>


struct prism{
   int length;
   int width;
   int height;
   double weight;
   char contents[25];
};
int main(){
   struct prism p={10,6,3,4.5,"Best Jewelry"};
   printf("Enter length and weight and height: ");
   scanf("%d%d%d",&p.length,&p.width,&p.height);
   printf("Enter weight: ");
   scanf("%lf",&p.weight);
   printf("Enter content: ");
   scanf("%s",&p.contents);
  
   printf("Length: %d\nWidth : %d\nHeight: %d\nWeight: %lf\tContents: %s",p.length,p.width,p.height,p.weight,p.contents);
  
  
  
}

9 #include <stdio.h> 12. struct prism{ int length; int width; int height; double weight; char contents [25]; int main({ struc

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Write a C Program 2. Write a program which defines a (hollow rectangular) prism as a...
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
  • Write a java program that computes the total surface area of a rectangular prism. There are...

    Write a java program that computes the total surface area of a rectangular prism. There are six sides, so the area of all six sides has to the summed to get the total area. The program should ask the user to enter the length (L), width (W) and the height )H) for the object in inches. Create a separate method from the main to calculate the area (name the method calcArea). The output of calcArea will return a double. Output;...

  • Write a C# application that implements a class ‘Prism’ with the following members. Five private data...

    Write a C# application that implements a class ‘Prism’ with the following members. Five private data members ‘length’, ‘height’, ‘width’, ‘Volume’ and ‘Area’ of double data type. Implement the constructor Prism( ) to accept the length, height, and width of the rectangular prism from the user. Implement three methods, Vol(), Area(), and Result() Vol() – to calculate the volume of the prism using the formulae Volume= length ×height ×width Area() – to calculate the surface area of the prism using...

  • Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate...

    Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate rectangle area. Some requirements: 1. User Scanner to collect user input for length & width 2. The formula is area = length * width 3. You must implement methods getLength, getWidth, getArea and displayData ▪ getLength – This method should ask the user to enter the rectangle’s length and then return that value as a double ▪ getWidth – This method should ask the...

  • ******** IN JAVA ********* I have a program that I need help debugging. This program should...

    ******** IN JAVA ********* I have a program that I need help debugging. This program should ask a user to input 3 dimensions of a rectangular block (length, width, and height), and then perform a volume and surface area calculation and display the results of both. It should only be done using local variables via methods and should have 4 methods: getInput, volBlock, saBlock, and display (should be void). I have most of it written here: import java.util.*; public class...

  • C Programming: Write a program that inputs two strings that represent floating-point values, convert the strings...

    C Programming: Write a program that inputs two strings that represent floating-point values, convert the strings to double values. Calculate the sum,difference,and product of these values and print them. int main(){    // character string value array for user    char stringValue[10];       double sum=0.0;// initialize sum to store the results from 2 double values       double difference=0.0; // initialize difference to store the results from 2 double values       double product = 0.0; // intitialzie product...

  • Write a program to display the area of a rectangle after accepting its length and width...

    Write a program to display the area of a rectangle after accepting its length and width from the user by means of the following functions: getLength – ask user to enter the length and return it as double getWidth – ask user to enter the width and return it as double getArea – pass width and length, compute area and return area displayArea – pass area and display it in this function. Expected Output: (i) Enter the length: 29 Enter...

  • Write a complete C++ program that defines the following class: Class Salesperson { public: Salesperson( );...

    Write a complete C++ program that defines the following class: Class Salesperson { public: Salesperson( ); // constructor ~Salesperson( ); // destructor Salesperson(double q1, double q2, double q3, double q4); // constructor void getsales( ); // Function to get 4 sales figures from user void setsales( int quarter, double sales); // Function to set 1 of 4 quarterly sales // figure. This function will be called // from function getsales ( ) every time a // user enters a sales...

  • Write a program named program51.py that defines a value-returning function named cuber that returns both the...

    Write a program named program51.py that defines a value-returning function named cuber that returns both the surface area and volume of a cube. A cube is a rectangular prism with all sides equal. Prompt the user to enter the cube's side length from the keyboard in the main function and then call the cuber function. Moving forward for all assignments and for this program, all other code would be in a main function, called at the very end of your...

  • Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the...

    Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the Area of a Circle 2.       Calculate the Area of a Triangle 3.     Calculate the Area of a Rectangle 4.       Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the formula:      area = ∏r2    Use 3.14159 for ∏. If the user enters 2 the program should ask for...

  • Write a program

    1. Write a program which have a class named as “Student”, while the data members of the class are,a. char name[10],b. int age;c. string color;d. string gender;e. double cgpa;and the member function “print()”,  is just to display these information.1. You need to create 3 objects of the “Student” class.2. Initialize one object by the default constructor having some static values.3. Initialize the second object by the parameterized constructor, while you need to pass values for initialization.4. Initialize the third object...

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