Multiplication Table

Multiplication Table by Mohit Purohit

C
O
D
E
/*

Creator - Mohit Purohit

Date      - 15 Feb. 2022

Time     - 8:00 P.M.

*/

#include <stdio.h>

#include <conio.h>

int main()

{

    clrscr();

    // Now I declare a variable and this name is 'num'. 'num' means number.

    // 'num' is a 'int'. 'num' means integer value.

    int num, restart = 0;

    // Here I use do while loop for restart this program.

    do

    {

        // User enter a number

        printf("Enter the number whose multiplication table you want to get.\n\n");

        scanf("%d", &num);

        //Presenting Multiplication Table

        printf("\nMultiplication Table of %d is -\n\n", num);

        // I am using two methods for printing multiplication table.

        // I am using for loop in both methods for printing the multiplication table.

        /* 

  Method 1 -

        

  for    (int i = 0 ; i <10; i++)

  

  {

      printf ("%d × %d = %d\n" ,num , i+1 , (i+1)*num);

   }

   */

        // Method 2 -

        for (int i = 1; i <= 10; i++)

        {

            printf("%d × %d = %d\n", num, i, i * num);

        }

        printf(" \n\n\n\n\nAre you want to explore another multiplication table? \nIf yes so write '1' otherwise you may enter any number\n");

        scanf("%d", &restart);

        if (restart == 1)

        {

            clrscr();

        }

    } while (restart == 1);

    //Thanks to user

    printf("\n\n\n👦👦I hope this is helpful for you👦👦\n\t - Mohit Purohit  \n\n\n\n");

    getch();

    return 0;

}

Comments

Popular posts from this blog