Pages

Adsense responsive

Friday, 3 April 2015

C++ PROGRAM: TO PRINT TABLE OF ANY NUMBER UPTO N

C++ program to print table of any number upto n using the concept of classes. This will take two inputs. First one for number whose table to be printed (For ex: 12)  and second is the number upto which table is to be printed (For ex: 17).

CODING:
#include<iostream.h>
#include<conio.h>
class table
{
 private:
  int num,upto,mul;
 public:
  table()
  {
   num=upto=0;
   mul=1;
  }
  table(int n,int u)
  {
   num=n;
   upto=u;
   mul=1;
  }
  void display()
  {
       for(int i=1; i<=upto; i++)
   {
    mul=num*i;
    cout<<endl<<num<<" * "<<i<<" = "<<mul;
   }
  }
};
void main()
{
 int n,u;
 clrscr();
 cout<<"Enter any number: ";
 cin>>n;
 cout<<"Table upto: ";
 cin>>u;
 table t1(n,u);
 t1.display();
 getch();
}
 

Images:

 
CODING OF C++ PROGRAM: TO PRINT TABLE OF ANY NUMBER UPTO N
Coding


Click on images to view them correctly.
 
OUTPUT OF C++ PROGRAM: TO PRINT TABLE OF ANY NUMBER UPTO N
Output




For any query or suggestion please comment below...


1 comment: