Algorithm
Multiplication Table
Adapted by Neilor Tonin, URI Brazil
Read an integer N (2 < N < 1000). Print the multiplication table of N.
1 x N = N 2 x N = 2N ... 10 x N = 10N
Input
The input is an integer N (1 < N < 1000).
Output
Print the multiplication table of N., like the following example.
Input Sample | Output Sample |
140 |
1 x 140 = 140 |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main()
{
int N, i;
scanf("%d", &N);
for (i = 1; i < = 10; i++) {
printf("%d x %d = %dn", i,N,i*N);
}
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main()
{
int n;
scanf("%i", &n);
printf("1 x %i = %in", n, n);
printf("2 x %i = %in", n, n * 2);
printf("3 x %i = %in", n, n * 3);
printf("4 x %i = %in", n, n * 4);
printf("5 x %i = %in", n, n * 5);
printf("6 x %i = %in", n, n * 6);
printf("7 x %i = %in", n, n * 7);
printf("8 x %i = %in", n, n * 8);
printf("9 x %i = %in", n, n * 9);
printf("10 x %i = %in", n, n * 10);
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#3 #3 Code Example with Another C++ Programming
Code -
C++ Programming
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
int n, i;
cin >> n;
for (i = 1; i < = 10; i++)
{
cout << i << " x " << n << " = " << i*n << endl;
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#4 Code Example with Java Programming
Code -
Java Programming
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int N;
Scanner input=new Scanner(System.in);
N =input.nextInt();
for (int i = 1; i < = 10; i++) {
System.out.print(i+" x "+N+" = "+(i*N)+"n");
}
}
}
Copy The Code &
Try With Live Editor
Input
Output
#5 Code Example with Python Programming
Code -
Python Programming
n=int(input())
for i in range(1,11):
print(f"{i} x {n} = {i*n}")
Copy The Code &
Try With Live Editor
Input
Output