Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
Program to Multiplication table in given range using Python

Multiplication table of a number in given range using C

Posted on October 25, 2020October 25, 2020

Table of Contents

  • Multiplication table of a number in given range using C
    • Multiplication table of a number in given range using C using for loop
    • Multiplication table of a number in given range using C- using while loop
    • Multiplication table of a number in given range using C- using do-while loop
    • Multiplication table of a number in given range using C- using function

Multiplication table of a number in given range using C

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

Multiplication table of a number in given range using C using for loop

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

 

  • integer variable num,i and range are declared.
  • The program asks input from the user
  • Then the user enters the input values for num and range
  • The program will read the input using Scanf() function and store to the variables num and range respectively
  • Create a for loop of i from 1 to 8 and increase the value of i after every iteration by 1
  • finally, the program displays the multiplication table using printf() function.

 

Multiplication table of a number in given range using C- using while loop

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

 

  • integer variable num,i and range are declared.
  • The program asks input from the user
  • Then the user enters the input values for num and range
  • The program will read the input using Scanf() function and store to the variables num respectively
  • Create a while loop of i from 1 to 12 and increase the value of i after every iteration by 1
  • finally, the program displays the multiplication table using printf() function.

 

Multiplication table of a number in given range using C- using do-while loop

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

 

  • integer variable num,i and range are declared.
  • The program asks input from the user
  • Then the user enters the input values for num and range
  • The program will read the input using Scanf() function and store to the variable num respectively
  • Create a do-while loop of i from 1 to 8 and increase the value of i after every iteration by 1
  • finally, the program displays the multiplication table using printf() function.

 

Multiplication table of a number in given range using C- using function

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

 

 

  • integer variable num,i and range are declared.
  • The program asks input from the user
  • Then the user enters the input values for num and range
  • The program will read the input using Scanf() function and store to the variable num and range respectively
  • Define the function  multipicationTable(int); to print multiplication table
  • Call the function to produce output
  • finally, the program displays the multiplication table using printf) function.

 

Suggested post

for loop in C language

while loop in C language

Do-while loop in C language

if statements in C language

Operator in C language

 

Similar post

Program to Display product of two numbers in Java

Program to Display product of two numbers in C

Program to Display product of two numbers in C++

Program to Display product of two numbers in Python

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes