Q. Write a program to display multiplication tables from ___ to ___ having n multiples each. The output should be displayed in a tabular format. For example, the multiplication tables of 2 to 9 having 10 multiples each is shown below.
2 × 1 = 2 3 × 1 = 3 ………….9 × 1 = 9
2 × 2 = 4 3 × 2 = 6…………..9 × 2 = 18
…………. …………. .................................
2 × 10 = 20 3 × 10 = 30………..9 × 10 = 90
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int j,i,s,l,temp;
printf("start :");
scanf("%d",&s);
printf("last :");
scanf("%d",&l);
if(s>l)
{
temp=s;
s=l;
l=temp;
}
printf("Multiplication table from %d to %d \n\n",s,l);
for(i=1;i<=10;i++)
{
for(j=s;j<=l;j++)
printf("%d\t",i*j);
printf("\n");
}
}
Output:
start :2
last :9
Multiplication table from 2 to 9
2 3 4 5 6 7 8 9
4 6 8 10 12 14 16 18
6 9 12 15 18 21 24 27
8 12 16 20 24 28 32 36
10 15 20 25 30 35 40 45
12 18 24 30 36 42 48 54
14 21 28 35 42 49 56 63
16 24 32 40 48 56 64 72
18 27 36 45 54 63 72 81
20 30 40 50 60 70 80 90
2 × 1 = 2 3 × 1 = 3 ………….9 × 1 = 9
2 × 2 = 4 3 × 2 = 6…………..9 × 2 = 18
…………. …………. .................................
2 × 10 = 20 3 × 10 = 30………..9 × 10 = 90
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int j,i,s,l,temp;
printf("start :");
scanf("%d",&s);
printf("last :");
scanf("%d",&l);
if(s>l)
{
temp=s;
s=l;
l=temp;
}
printf("Multiplication table from %d to %d \n\n",s,l);
for(i=1;i<=10;i++)
{
for(j=s;j<=l;j++)
printf("%d\t",i*j);
printf("\n");
}
}
Output:
start :2
last :9
Multiplication table from 2 to 9
2 3 4 5 6 7 8 9
4 6 8 10 12 14 16 18
6 9 12 15 18 21 24 27
8 12 16 20 24 28 32 36
10 15 20 25 30 35 40 45
12 18 24 30 36 42 48 54
14 21 28 35 42 49 56 63
16 24 32 40 48 56 64 72
18 27 36 45 54 63 72 81
20 30 40 50 60 70 80 90
0 Comments