Menu

Add Topic

Forum

waiting answer July 12, 2021

C Program to Print Multiplication Table of a given Number

Answers
January 20, 2021

Program Description: c program to print table of a given number

    #include <stdio.h>
    int main() {
        int num, i, rng;
        printf("Enter an integer number: ");
        scanf("%d", &num);
        printf("Enter the range or limit: ");
        scanf("%d", &rng);
        for (i = 1; i <= rng; ++i) {
            printf("\n%d * %d = %d", num, i, num * i);
        }
        return 0;
    }

OUTPUT

         Enter an integer number: 5
         Enter the range or limit: 5
         5 * 1 = 5
         5 * 2 = 10
         5 * 3 = 15
         5 * 4 = 20
         5 * 5 = 25

0 0
January 20, 2021

Required knowledge: basics of c programming, loops, arithmetic, and relational operators

    #include <stdio.h>
    int main()
    {
        int num, i = 1;
        printf(" Enter the Number:");
        scanf("%d", &num);
        while (i <= 10)
        {
            printf("\n%d x %d = %d", num, i, num * i);
            i++;
        }
        return 0;
    }

OUTPUT

          Enter the Number:5
          5 x 1 = 5
          5 x 2 = 10
          5 x 3 = 15
          5 x 4 = 20
          5 x 5 = 25
          5 x 6 = 30
          5 x 7 = 35
          5 x 8 = 40
          5 x 9 = 45
          5 x 10 = 50    

0 0
January 20, 2021

In this example, you will learn how to print a table of a given number

This program inputs a number 10 and generates the multiplication table up to 10.

    #include 
	int main() {
	    int number;
	    int i;
	    printf("Enter an integer number: ");
	    scanf("%d", &number);
	    for (i = 1; i <= 10; ++i) {
	        printf("%d * %d = %d", number, i, number * i);
	        printf("\n");
	    }
	    return 0;
	}

OUTPUT

Enter an integer number: 10
         10 * 1 = 10
         10 * 2 = 20
         10 * 3 = 30
         10 * 4 = 40
         10 * 5 = 50
         10 * 6 = 60
         10 * 7 = 70
         10 * 8 = 80
         10 * 9 = 90
         10 * 10 = 100

0 0

Please Login to Post the answer

Leave an Answer