Assingment No 8

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

ASSINGMENT NO.

9
Write a program to find out the square and cube of a number.

#include<iostream>
using namespace std;

class Test {
public:
    int num, square, cube;

    void input() {
        cout<<"FE21IF024 Chaitanya Girgaonkar"<<endl;
        cout << "Enter a number:";
        cin >> num;
    }

    void findSquare() {
        square = num * num;
    }

    void findCube() {
        cube = num * num * num;
    }

    void display() {
        cout << "Square is:" << square;
        cout << "\nCube is:" << cube;

    }
};

int main() {

    Test obj;
    obj.input();
    obj.findSquare();
    obj.findCube();
    obj.display();

    return 0;
}

 OUTPUT

You might also like