Printing Multiplication Table in Descending Order Using For Loop in C


This program is written in the C programming language and is used to generate and print the multiplication table of a given number in descending order up to a given limit. The program starts by including the standard input/output library (stdio.h) and then defines a main function. Within the main function, the program declares three variables: "i", "n" and "a". The variable "n" is initialized to 1, "a" is used to store the number for which the multiplication table is to be generated and "i" is used as a loop counter.

The program then prompts the user to enter the limit using the "printf" function and stores the value in the variable "i" using the "scanf" function. Next, it prompts the user to enter the number for which the multiplication table is to be generated, and stores the value in the variable "a" using the "scanf" function. Next, the program uses a "for" loop with the counter variable "i" which is initialized with the value entered by user, The loop continues as long as i is greater than or equal to n. Within this loop, it uses the "printf" function to print the current value of "i", the value of "a" and the result of multiplying "i" and "a" on each iteration of the loop.

Finally, the program returns 0 to indicate that the program has completed successfully. This program will take two inputs from the user, one is the limit to which the table should be generated and another is the number for which the table should be generated. The program then uses a for loop to iterate from the limit to 1 in descending order and in each iteration, it multiplies the number entered by the user and the current value of the counter and prints the result.

Source Code

#include<stdio.h>
int main()
{
  int i,n=1,m,a;
  printf("\nEnter the limit:");
  scanf("%d",&i);
  printf("\nEnter the table's number:");
  scanf("%d",&a);
  for(i;i>=n;i--)
  {
    printf("\n%d*%d=%d",i,a,i*a);
  }
  return 0;
}
To download raw file Click Here

Output

Enter the limit:8
Enter the table's number :2
8*2=16
7*2=14
6*2=12
5*2=10
4*2=8
3*2=6
2*2=4
1*2=2

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C