Write a program that prints a multiplication table for a given number and the number of rows inthe table. For example, for a number 5 and rows = 3, the output should be: 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15.
Write a program that prints a multiplication table for a given number and the number of rows inthe table. For example, for a number 5 and rows = 3, the output should be:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15.
Algorithm
start
step1: Read a,r
step2: for i := 1 to r step 1 do
step3: Print a * i
stop
Flowchart
C Programming
// multiplication table for a given number and the number of rows inthe table
#include <stdio.h>
int main()
{
int a,r,i;
printf("Enter an integer number : ");
scanf("%d",&a);
printf("Enter number of rows : ");
scanf("%d",&r);
for(i=1;i<=r;i++)
printf("%d * %2d = %2d\n",a,i,a*i);
return(0);
}
OUTPUT
Enter an integer number : 6
Enter number of rows : 10
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
6 * 10 = 60
๐ป Run This C Program
Write a program that prints a multiplication table for a given number and the number of rows inthe table. For example, for a number 5 and rows = 3, the output should be:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15.
The selected C program is loaded automatically. Edit the code,
provide input through STDIN and click Run.
The compiler is embedded using OneCompiler. Your program runs in
the embedded C environment; Study Glance does not execute C code
directly on your web server.