Read Data Member of class using construction. find volume with constructor..

Find the volume of Box using construcor   ..

image is taken ffom another website

 



#include<iostream>

#include<conio.h>

using namespace std;

 class Box

 {

private:

    float l,b,h;

public:

    Box(float le, float br, float he)

    {

        l=le;

        b=br;

        h=he;

    }

    float getvolume()

    {

        return(l*b*h);

    }

 };

 int main(){

 float vol;

 Box ob(10,3.5,5.5);

 vol=ob.getvolume();

 cout<<"The volume of Box is:"<<vol;

 return 0;

 getch();

 };


No comments:

Post a Comment

Write a C program that: 1. Accepts the total purchase amount, customer type, and season from the user. 2. Uses nested if-else statements to calculate and display the final amount after applying the discount.

Here is a C Program for Customer and Day Based Shop Management Program  #include <stdio.h> int main () {     char name [ 20 ];     ...

Contact form

Name

Email *

Message *

loading...