Printing reverse tables using For Loop in C++


This is a C++ program that prompts the user to input a limit and a number, and then outputs the multiplication table of that number up to the limit in reverse order. Here is a brief explanation of the program:

  • The program declares four integer variables: i, n, m, and a, and initializes n to 1 and i to the limit entered by the user.
  • The program prompts the user to input the limit and the number, and reads them from the standard input using the cin object.
  • The program enters a for loop that iterates i-n+1 times, where n is 1 and i is the limit entered by the user. In each iteration, the loop body is executed.
  • In the loop body, the program outputs the current value of i and the product of i and a, separated by the * and = characters, respectively. The output is sent to the standard output using the cout object.
  • After the loop terminates, the program returns 0 to the operating system, indicating successful execution.

Source Code

#include<iostream>
using namespace std;
int main()
{
    int i,n=1,m,a;
    cout<<"\nEnter the limit:";
    cin>>i;
    cout<<"\nEnter the table's number:";
    cin>>a;
    for(i;i>=n;i--)
    {
        cout<<"\n"<<i<<"*"<<a<<"="<<i*a;
    }
    return 0;
}
To download raw file Click Here

Output

Enter the limit:10
Enter the table's number:5
10*5=50
9*5=45
8*5=40
7*5=35
6*5=30
5*5=25
4*5=20
3*5=15
2*5=10
1*5=5

Program List


Flow Control

IF Statement Examples


Switch Case


Goto Statement


Break and Continue


While Loop


Do While Loop


For Loop


Friend Function in C++


String Examples


Array Examples


Structure Examples


Structure & Pointer Examples


Structure & Functions Examples


Enumeration Examples


Template Examples


Functions


Inheritance Examples

Hierarchical Inheritance


Hybrid Inheritance


Multilevel Inheritance


Multiple Inheritance


Single Level Inheritance


Class and Objects

Constructor Example


Destructor Example


Operator Overloading Example


Operator and Function Example


List of Programs


Pointer Examples


Memory Management Examples


Pointers and Arrays


Virtual Function Examples