Posts

Write a c++ program using class to calculate cube and square of a given number using inline function.

Write a c++ program using class to calculate cube and square of a given number using inline function. #include<iostream.h> #include<conio.h> class calc { int no; public:inline void number()        {        int square,cube;        cout<<"Enter the number";        cin>>no;        square=no*no;        cube=no*no*no;        cout<<"Square of a given number is:-"<<square;        cout<<"\n Cube of a given number is:-"<<cube;        }        }; int main() { calc c; clrscr(); c.number(); getch(); return 0; } ====================================================== OUTPUT:- Enter the number5 Square of a given number is:-25 Cube of a given number is:-...

Write a c++ program using class to overload the operator unary decrement -- for an integer number.

Write a c++ program using class to overload the operator unary decrement -- for an integer number. #include<conio.h> #include<iostream.h> class decrement { public:int no; public:void getdata()        {        cout<<"\n Enter the number:-";        cin>>no;        }        void operator --()        {        no=no-1;        }        void display()        {        cout<<"\n The number after decrement is:-"<<no;        } }; int main() { decrement i; clrscr(); i.getdata(); --i; i.display(); getch(); return 0; } ================================================== OUTPUT Enter the number:-6 T...