Ex: Write a C program to print multiplication table of given number. How to write a C program to print multiplication table of given number. C program to print multiplication table of given number.
Input from user:
Enter the number: 12
Expected output:
Multiplication table of 12 is:
12x1=12
12x2=24
12x3=36
12x4=48
12x5=60
12x6=72
12x7=84
12x8=96
12x9=108
12x10=120
1. Accept input number from user.
2. Use for loop to print multiplication table. for loop will iterate 1 to 10. for(i=1;i<=10;i++)
3. inside the for loop print multiplication table using no*i.
#include<stdio.h>
int main()
{
int no,i;
printf("Enter the number\n");
scanf("%d",&no);
printf("Multiplication table of %d is:\n",no);
for(i=1;i<=10;i++)
{
printf("%dx%d=%d\n",no,i,(no*i));
}
return 0;
}
Above prgram shows the following output:
Input from user:
Enter the number: 12
Expected output:
Multiplication table of 12 is:
12x1=12
12x2=24
12x3=36
12x4=48
12x5=60
12x6=72
12x7=84
12x8=96
12x9=108
12x10=120
Step by step logic of the given program:
1. Accept input number from user.
2. Use for loop to print multiplication table. for loop will iterate 1 to 10. for(i=1;i<=10;i++)
3. inside the for loop print multiplication table using no*i.
C program to print multiplication table of given number :
#include<stdio.h>
int main()
{
int no,i;
printf("Enter the number\n");
scanf("%d",&no);
printf("Multiplication table of %d is:\n",no);
for(i=1;i<=10;i++)
{
printf("%dx%d=%d\n",no,i,(no*i));
}
return 0;
}
Above prgram shows the following output: