Coding Practice

Write a C program to print multiplication table of any number

Print multiplication table of any number
Sample Output
Enter a number: 5
Enter limit: 10
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50

Process returned 0 (0x0)   execution time : 33.760 s
Press any key to continue.
Source Code
#include<stdio.h>

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

    printf("Enter a number: ");
    scanf("%d", &num);

    scanf("%d", &limit, printf("Enter limit: "));

    for(n = 1; n <= limit; n++)
    {
        printf("%d * %d = %d\n", num, n, num * n);
    }
    return 0;
}
Sample Output
Enter a number: 7
Enter limit: 5
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35

Process returned 0 (0x0)   execution time : 24.210 s
Press any key to continue.

No comments:

Post a Comment

Change Theme
X