Saturday, 2 April 2016

Compound Types (C++ Primer Plus Sixth Edition Solution Manual Question # 8)

Leave a Comment
Explanation:
Below mention code is compiled in Visual Studio 2015 and Code Blocks 13.12,output snap is attached.. If any problem you feel and you want some explanation feel free to contact us.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/


/*
Do Programming Exercise 7, but use new to allocate a structure instead of declaring a
structure variable. Also, have the program request the pizza diameter before it requests
the pizza company name.
*/

#include <iostream>
#include <string>

using namespace std;

struct sPizza {
       string name;
       double diameter;
       double weight;
};

int main() {
       sPizza * pp = new sPizza;
       cout << "Enter the pizza company name: ";
       getline(cin, pp->name);
       cout << "Enter the diameter of pizza: ";
       cin >> pp->diameter;
       cout << "Enter the weight of pizza: ";
       cin >> pp->weight;

       cout << "Pizza Company: " << pp->name << endl
              << "Pizza Diameter: " << pp->diameter << endl
              << "Pizza Weight: " << pp->weight << endl;
       delete pp;
       return 0;
}



Output:


Related Articles:

C++ Primer Plus Sixth Edition Complete Solution Manual 

C++ Books Solution

If You Enjoyed This, Take 5 Seconds To Share It