C program to print multiplication table of 1 to 10
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, p;
for(i=1;i<=10;i++)
{
for(j=1;j<=10;j++)
{
p = i*j;
printf("\n %d*%d = %d", i, j, p);
}
printf("\n");
}
getch();
}
Output
How does the program work?
To print multiplication table we use nested loop. When the body of loop contains another loop the inner loop is called nested loop with outer loop.
The first loop for(i=1;i<=10;i++)is continue till the value of i reached 10.
for(j=1;j<=10;j++) is also continue till the value of j reached 10.
p = i*j; calculate the product of i and j and store value in p.
printf("\n %d*%d = %d", i, j, p); display as below
\n helps to get crosser in second line and %d*%d = %d display as i*j =p

0 Comments
Please do not enter any spam link on comment box