Multiplication using for loop.
C Program to print multiplication table using "for loop".
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
printf("Multiplication table\n\n");
printf("Here multiplication table\n\n");
for(i=1; i<=10; i++){
for(j=1; j<=10; j++){
printf("%d\t", i*j);
}
printf("\n");
}
getch();
}
Expected Output:
C Program to print multiplication table using "while loop".
#include <stdio.h>
#include <conio.h>
void main()
{
int i=1;
printf("Multiplication table\n\n");
printf("Here multiplication table\n\n");
while(i<=10){
int j=1;
while(j<=10){
printf("%d\t",i*j);
j++;
}
i++;
printf("\n");
}
getch();
}
#include <conio.h>
void main()
{
int i=1;
printf("Multiplication table\n\n");
printf("Here multiplication table\n\n");
while(i<=10){
int j=1;
while(j<=10){
printf("%d\t",i*j);
j++;
}
i++;
printf("\n");
}
getch();
}
Expected Output:
Output will be same as given above image.
C Program to print multiplication table using "do-while loop".
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
i=1;
printf("Multiplication table\n\n");
printf("Here multiplication table\n\n");
do{
j=1;
do{
printf("%5d\t",i*j);
j++;
}while(j<=10);
printf("\n");
i++;
}while(i<=10);
getch();
}
#include <conio.h>
void main()
{
int i,j;
i=1;
printf("Multiplication table\n\n");
printf("Here multiplication table\n\n");
do{
j=1;
do{
printf("%5d\t",i*j);
j++;
}while(j<=10);
printf("\n");
i++;
}while(i<=10);
getch();
}
Expected Output:
Output will be same as given above image.
Tags:
C program to print multiplication using for
c programming by mskuthar
mskuthar
while and do-while loop