Program to print multiplication table of n up to m using For loop
- Write a program to print multiplication table of n up to m using For loop in C
- Write a program to print multiplication table of n up to m using For loop in C++
- Write a program to print multiplication table of n up to m using For loop in Python
- Write a program to print multiplication table of n up to m using For loop in PHP
- Write a program to print multiplication table of n up to m using For loop in Java
- Write a program to print multiplication table of n up to m using For loop in Java Script
- Write a program to print multiplication table of n up to m using For loop in C#
Explanation:
Using a for loop, you multiply n by each integer from 1 to m and display the result to print the multiplication table of a number n up to m.
Logic
- Take inputs for n (the number for which the table is to be printed) and m (the limit up to which the table is printed).
- Use a for lop to iterate from 1 to m.
- In each iteration, calculate n × i and display the result.
Program to print multiplication table of n up to m using For loop
-
C
-
C++
-
Python
-
PHP
-
JAVA
-
Java Script
-
C#
#include <stdio.h>
int main() {
int n, m;
printf("Enter the number for the multiplication table (n): ");
scanf("%d", &n);
printf("Enter the limit for the multiplication table (m): ");
scanf("%d", &m);
for (int i = 1; i <= m; i++) {
printf("%d x %d = %d\n", n, i, n * i);
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
int n, m;
cout << "Enter the number for the multiplication table (n): ";
cin >> n;
cout << "Enter the limit for the multiplication table (m): ";
cin >> m;
for (int i = 1; i <= m; i++) {
cout << n << " x " << i << " = " << n * i << endl;
}
return 0;
}
n = int(input("Enter the number for the multiplication table (n): "))
m = int(input("Enter the limit for the multiplication table (m): "))
for i in range(1, m + 1):
print(f"{n} x {i} = {n * i}")
<?php
$n = (int)readline("Enter the number for the multiplication table (n): ");
$m = (int)readline("Enter the limit for the multiplication table (m): ");
for ($i = 1; $i <= $m; $i++) {
echo "$n x $i = " . ($n * $i) . "\n";
}
?>
import java.util.Scanner;
public class MultiplicationTable {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number for the multiplication table (n): ");
int n = scanner.nextInt();
System.out.print("Enter the limit for the multiplication table (m): ");
int m = scanner.nextInt();
for (int i = 1; i <= m; i++) {
System.out.println(n + " x " + i + " = " + (n * i));
}
scanner.close();
}
}
let n = parseInt(prompt("Enter the number for the multiplication table (n):"));
let m = parseInt(prompt("Enter the limit for the multiplication table (m):"));
for (let i = 1; i <= m; i++) {
console.log(`${n} x ${i} = ${n * i}`);
}
using System;
class Program {
static void Main() {
Console.Write("Enter the number for the multiplication table (n): ");
int n = int.Parse(Console.ReadLine());
Console.Write("Enter the limit for the multiplication table (m): ");
int m = int.Parse(Console.ReadLine());
for (int i = 1; i <= m; i++) {
Console.WriteLine($"{n} x {i} = {n * i}");
}
}
}