Program to display multiplication table of a number

Description

To display Multiplication table up to 10,
take a loop from 1 to 10 and multiply the number from 1 to 10.

C/C++

/* C Program to display multiplication table of a number */
//Save it as MultiplicationTable.c

#include<stdio.h>
int main(){

    int i, n;

    printf("Enter a number : ");
    scanf("%d",&n);

    printf("Multiplication table of %d is : \n",n);

    for(i=1;i<=10;i++){
        printf("%d x %d = %d\n",n,i,n*i);
    }

    return 0;
}
Input:
Enter a number : 
8

Output:
Multiplication table of 8 is : 
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
8 x 4 = 32
8 x 5 = 40
8 x 6 = 48
8 x 7 = 56
8 x 8 = 64
8 x 9 = 72
8 x 10 = 80

Java

/* Java Program to display multiplication table of a number */
//Save it as MultiplicationTable.java

import java.io.*;
import java.util.Scanner;

public class MultiplicationTable {

    public static void main(String[] args) {

         Scanner scanner = new Scanner(System.in);
        
        int i, n;
        System.out.println("Enter a number : ");
        n = scanner.nextInt();

        System.out.println("Multiplication table of "+n+" is : ");

        for(i=1;i<=10;i++){
            System.out.println(n+" x "+i+" = "+n*i);
        }
    }
}
Input:
Enter a number : 
8

Output:
Multiplication table of 8 is : 
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
8 x 4 = 32
8 x 5 = 40
8 x 6 = 48
8 x 7 = 56
8 x 8 = 64
8 x 9 = 72
8 x 10 = 80

Related Programs

1) Program to calculate Factorial of a Number
2) Program to generate Random number in a given Range
3) Program to calculate Gross Salary
4) Program to calculate Grade of Student
5) Program to convert Decimal to Octal
6) Program to find sum of first and last digit of a number
7) Program to find largest and smallest digit in a Number
8) Program to find largest and smallest character in a String
9) Program to add two complex numbers
10) Program To Check Armstrong Number
Share Me

Leave a Reply