Monday, April 17, 2017

C++ code to Convert Inch into Centimeter

This is the solution to convert Inch into Centimeter in C++ (T.U. 2068)

#include <iostream>

using namespace std;

class InchtoCentimeter
{
    float Inch, Centimeter ;
public:

    void GetInch();
    void Conversion();
    void print();
};


void InchtoCentimeter::GetInch()
{
    cout << endl << "Enter inch:" ;
    cin >> Inch ;
}

void InchtoCentimeter::Conversion()
{
    Centimeter = 2.54*Inch ;
}

void InchtoCentimeter::print()
{
    cout << endl << "Inch=" << Inch << endl << "Centimeter=" << Centimeter << endl ;
}

int main()
{
    InchtoCentimeter d;
    d.GetInch();
    d.Conversion();
    d.print();
    return 0;
}

No comments:

Post a Comment