C++ Program to print Table of number using Function

ad+1

In this program we are going to print table of any number using function. Actually we will take input of an integer from a user and then we will pass that number to a function. And after passing number to function we will find table of that number using for loop.

Program:

// Program By http://solutionscpp.blogspot.com
// Author Mansoor Ahmed
// GMail ID: secguy000@gmail.com


#include<iostream>
using namespace std;

int table(int n);

int main()
{

  int n=0;

  cout<<"Enter Number: ";
  cin>>n;

  table(n);

}

int table(int n)
{
    int t=1;
   
  cout<<"Table of " <<n << " is: " <<endl;
 
  for(int i=1; i<=10; i++)
  {
     t=n*i;
   
     cout<<n <<" * " <<i <<" = " <<t <<endl;
   
  }
 
  return 0;
}

 

Output:

 

9 comments: Leave Your Comments

  1. Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a bit, but instead of that, this is excellent blog. A fantastic read. I'll definitely be back.
    beta afp browser

    ReplyDelete
  2. I found nice article in your blog.thank you for useful info
    .

    ReplyDelete
  3. Informative article. Thanks for sharing such an valuable article. Also visit my website for Solid Inkjet Helpline. Solid Inkjet Helpline

    ReplyDelete
  4. Write a C program to Print table of entered number by user through keyboard using for loop.

    Code of given problem:
    int main()

    {
    int i=0,num;
    printf("Enter the number to find its table:\t");
    scanf("%d", &num);
    for(i=1;i<=10;i++)
    {
    printf("%d\n",num*i);
    }
    return 0;
    }

    Very informative blog!

    Please take some time to visit my blog @
    for loop program examples

    Thanks!

    ReplyDelete
  5. Amazing . I kind of understood it somehow but what does table (n) say? thank you

    ReplyDelete
  6. Amazing and very helpful for me thank you...

    ReplyDelete