This blog is under construction

Tuesday 9 July 2013

C program to generate multiplication table for the given number

Write a C program to generate multiplication table for the given number.


  #include <stdio.h>

  int main() {
        int num, limit, i;

        /* get the desired multiplication table from user */
        printf("Enter the desired multiplication table:");
        scanf("%d", &num);

        /* get the limit for the above table from the user */
        printf("Enter the limit for the table:");
        scanf("%d", &limit);

        /* print the multiplication table */
        for (i = 1; i <= limit; i++) {
                printf("%d X %d = %d\n", num, i, num * i);
        }

        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Enter the desired multiplication table:16
  Enter the limit for the table:16
  16 X 1 = 16
  16 X 2 = 32
  16 X 3 = 48
  16 X 4 = 64
  16 X 5 = 80
  16 X 6 = 96
  16 X 7 = 112
  16 X 8 = 128
  16 X 9 = 144
  16 X 10 = 160
  16 X 11 = 176
  16 X 12 = 192
  16 X 13 = 208
  16 X 14 = 224
  16 X 15 = 240
  16 X 16 = 256






See Also:

No comments:

Post a Comment