-->





c++ multiplication table using while loop example

C++ simple program which uses while loop to print a multiplication table in a proper format. User inputs a number for table then limit. 
program has tested on code blocks c++ compiler.

source code:
#include<iostream>
#include<conio.h>
#include<iomanip>
using namespace std;
int main()
{
    int n,c=1,limit;
    cout<<"Enter number to print its table=";
    cin>>n;
    cout<<"Enter limit=";
    cin>>limit;
    while(c<=limit)
    {
       cout<<n<<" * "<<setw(2)<<c<<" = "<<setw(2)<<n*c<<endl;
       c++;
    }

getch();
}


program output:
c++ multiplication table using while loop example output


find more examples here: C++ simple examples with source codes

1 comment: