Table of Contents
In this article, we will discuss the concept of Multiplication table of a number in given range using C
In this program, we are going to learn how to generate a multiplication table using several ways in C language.
This is done using for loop , while loop , do-while loop and function in C language
In this program, we will display multiplication table of a number in given range using for loop in C language
Program 1
#include <stdio.h> #include <stdlib.h> int main() { int i,num,range; printf("Enter the any number\n"); scanf("%d",&num); printf("Enter the range\n"); scanf("%d",&range); for(i=1; i<=range; i++){ printf("%dx%d = %d\n",num,i,num*i); } getch(); return 0; }
When the above code is executed, it produces the following result
Enter the any number: 4 Enter the range: 8 4x1=4 4x2=8 4x3=12 4x4=16 4x5=20 4x6=24 4x7=28 4x8=32
In this program, we will display multiplication table of a number in given range using while loop in C language
Program 2
#include <stdio.h> #include <stdlib.h> int main() { int i,num,range; printf("Enter the any number\n"); scanf("%d",&num); printf("Enter the range\n"); scanf("%d",&range); i=1; while(i<=range){ printf("%dx%d = %d\n",num,i,num*i); i++; } getch(); return 0; }
When the above code is executed, it produces the following result
Enter the any number: 10 Enter the range: 12 10x1=10 10x2=20 10x3=20 10x4=40 10x5=50 10x6=60 10x7=70 10x8=80 10x9=90 10x10=100 10x11=110 10x12=120
In this program, we will display multiplication table of a number in given range using do-while loop in C language
Program 3
#include <stdio.h> #include <stdlib.h> int main() { int i,num,range; printf("Enter the any number\n"); scanf("%d",&num); printf("Enter the range\n"); scanf("%d",&range); i=1; do{ printf("%dx%d = %d\n",num,i,num*i); i++; } while(i<=range); getch(); return 0; }
When the above code is executed, it produces the following result
Enter the any number: 6 Enter the range: 8 6x1=6 6x2=12 6x3=18 6x4=24 6x5=30 6x6=36 6x7=42 6x8=48
In this program, we will display multiplication table of a number in given range using function in C language
Program 4
#include <stdio.h> #include <stdlib.h> void mutipication_Table(int num, int range){//define the function int count; for(count=1; count<=range; count++){ printf("%d x %d = %d\n",num,count,num*count); } } int main() { int num,range; printf("Enter a number: \n"); scanf("%d",&num); printf("Enter the range: \n"); scanf("%d",&range); mutipication_Table(num,range);//call the function getch(); return 0; }
When the above code is executed, it produces the following result
Enter the a number: 8 Enter the range: 12 8x1=8 8x2=16 8x3=24 8x4=32 8x5=40 8x6=48 8x7=56 8x8=64 8x9=72 8x10=80 8x11=88 8x12=96
Suggested post
Similar post
Program to Display product of two numbers in Java
Program to Display product of two numbers in C
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.