Program statement
Write a program to take any number from user and print table of given number as output.
For example:
Table of 5
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
Program to print table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include<stdio.h> int main() { int num, i, j; printf("Enter a number\n"); scanf("%d",&num); printf("Table of number %d is\n",num); for(i=num; i<num+1; i++) { for(j=1; j<=10; j++) { int k = i*j; printf("%d * %d = %d\n", i, j, k); } printf("\n"); } } |
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Enter a number 76 Table of number 76 is 76 * 1 = 76 76 * 2 = 152 76 * 3 = 228 76 * 4 = 304 76 * 5 = 380 76 * 6 = 456 76 * 7 = 532 76 * 8 = 608 76 * 9 = 684 76 * 10 = 760 |