Here in this, we will code a program that will accept an integer from a user and print a table for that number.

For example, if the user enters 7 then the program will print the table of 7.

Multiples of a Number

C++:

#include<iostream.h>
#include< conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
int n;
cout<<" Enter a number:  ";
cin>>n;
for(int i =1; i<=10;i++)
cout<<n<<"*"<<i<<"= "<<i*n<<"\n";
getch();
}

Output:

Enter a number: 10

10*1= 10
10*2= 20
10*3= 30
10*4= 40
10*5= 50
10*6= 60
10*7= 70
10*8= 80
10*9= 90
10*10= 100

Python:

n= int(input("Enter a number: "))
for i in range(1,11):
    print(str(n)+"*"+str(i)+"=",i*n)

Output:

Enter a number: 7

7*1= 7
7*2= 14
7*3= 21
7*4= 28
7*5= 35
7*6= 42
7*7= 49
7*8= 56
7*9= 63
7*10= 70

Leave a Reply

Your email address will not be published. Required fields are marked *