Written by Sai Sameera Thota on January 7, 2013 in C > C++ > Java > Programming

C Program to Print Multiplication Table

GET ALERTS:

Get our Latest updates delivered to your mailbox!

This is a tiny and very easy program which prints Multiplication table of a given number. i will be incremented as it is attached to for loop. And the logic within the loop is just a normal multiplication n*i where n is the user input and i is our variable.

This program will print first 10 multiples of the given number, you can change it to 20, 30 or some other value of your choice by simply modifying i<=NUMBER.

Multiplication Table Program in C

//C Program to Print Multiplication Table :
#include<stdio.h>
#include<conio.h>
void main()
{
      int n,i;
      clrscr();
      printf("Enter a digit to print its multiplication table : ");
      scanf("%d",&n);
      for(i=1;i<=10;i++)
      {
                        printf("%d * %d = %d\n",n,i,n*i);
      }
      getch();
}

C++ Program to Print Multiplication Table

#include<iostream.h>
#include<conio.h>
void main()
{
      int n,i;
      clrscr();
      cout<<"Enter a digit to print its multiplication table : ";
      cin>>n;
	  cout<<"\n";
      for(i=1;i<=10;i++)
      {
                        cout<<n<<" * "<<i<<" = "<<n*i;
      }
      getch();
}

Output:
Multiplication-Table-Program

Multiplication Table in Java

import java.io.*;
class table 
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.print("\nEnter an integer to display the multiplication table :");
		int n = Integer.parseInt(br.readLine());
		System.out.println("\n====================");
		for(int i=1;i<=10;i++)
		{
			System.out.println(n +" * "+ i +" = "+ n*i);
		}
		System.out.println("====================");
	}
}

Output:
multiplication-table-in-java

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: