google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.

Saturday, February 28, 2015

Write a C++ program to Design a class which contain static data member and member function show()

Design a class which contain static data member and member function show() which display number of times display operation is performed irrespective of the object responsible for display using static data
member.

#include<conio.h>
#include<iostream.h>
class number
{
public:static int cnt;
public:static void show()
       {
       cnt++;
       cout<<"\n Number of times display operation is performed:-"<<cnt;
       }
};
int number::cnt;
int main()
{
number n1,n2,n3,n4;
clrscr();
n1.show();
n2.show();
n3.show();
n4.show();
getch();
return 0;
}


==================================================
OUTPUT

Number of times display operation is performed:-1
Number of times display operation is performed:-2
Number of times display operation is performed:-3
Number of times display operation is performed:-4

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:-125

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...