Math Table generator using C

  In this article, we will create a simple math multiplication table generator using C.


Math table generator using C
Math Table Generator using C


The following header files are used -

  • stdio.h - For standard input or output operations.


The following user-defined functions are created -

  • tables(int n, int s, int e) - This function takes the number whose multiplication table the user wants to generate along with the starting range and ending range, and prints the same. This function doesn't return anything.


Code - 

//Math Tables generator using C by Vishruth Codes
#include<stdio.h>

void tables(int n, int s, int e)
{
    for(int i=s;i<=e;i++)
    {
        printf("\n%d x %d = %d",n,i,n*i);
    }
}

int main()
{
    int n,srange,erange;
    printf("\nEnter the Number: ");
    scanf("%d",&n);
    printf("\nEnter the starting range: ");
    scanf("%d",&srange);
    printf("\nEnter the ending range: ");
    scanf("%d",&erange);
    tables(n,srange,erange);
}


Subject - 

In the above example, I have implemented a simple multiplication table generator using C using the concept of iteration and functions.


Basic features - 

  • Prints multiplication table of any given integer.
  • The user can set the starting range and ending range of the multiplication table.


Working - 

  1. The main() function takes the number (n) whose multiplication table is to be generated along with the starting range (srange) and ending range (erange).
  2. Function tables is called by the main() function by passing all the inputs given by the user, which prints out the multiplication table accordingly, using the 'for' loop. 


Output - 

Multiplication table generator program
Sample Output




Thanks for reading. If you found any errors or have suggestions to improve the article, please mention them in the comments.



Post a Comment

0 Comments