Tuesday, 8 September 2020

Alternative method to find the multiplication table.

/*Program to find the multiplication table*/
#include<stdio.h>

int main()
{
  int a,b, n, end, mul;
  printf("5 * 10, where 5 is prfix and 10 is suffix! ");
  printf("Enter the prefix number upto which  you want table: ");
  scanf("%d", &n);
  printf("Enter the suffix number till where you want table: ");
  scanf("%d", &end);
  printf("The multiplication table of 1 to %d is: ",n);
  for(a = 1; a<=n; a++)
   {
  for(b = 1; b <=end; b++)
       {
mul = a*b;
printf("%d * %d = %d ",a,b,mul);
}
printf("\n\n");
  }
return 0;
}
OUTPUT:



Description:
This program will take two inputs from user .First number will represent the number till where you want multiplication table and second number will multiply first numbers till you given it's value.

Example-If you want to get the table upto 5 at once then just keep the value of prefix 5 and if you need it up to 10 times then keep the value of suffix 10.

No comments:

Post a Comment

If you have any doubt, please ask in the comment section.

Search This Blog

Program to print weather the number is happy or not.

#include <stdio.h> #include <math.h> int main () { int i , j , num , temp , sum = 0 ; printf ( "Enter number\n...