Object
Write a program to print the table of a given number.
Algorithm
- Declare integer variables num and i.
- Read num.
- Set i = 1.
- Repeat WHILE i <= 10
- Write num*i.
- i++.
- [End of WHILE loop.]
- Exit.
Flowchart

C++ Source Code
// program 53
#include<iostream>
using namespace std;
int main()
{
int num, i;
cout << "Enter any number: ";
cin >> num;
i = 1;
while (i <= 10)
{
cout << "\n" << num << " * " << i << " = " << num * i;
i++;
}
return 0;
}
C Source Code
/*program 53*/
#include<stdio.h>
int main()
{
int num, i;
printf("Enter any number: ");
scanf("%d", &num);
i = 1;
while(i<=10)
{
printf("\n%d * %d = %d", num, i, num*i);
i++;
}
return 0;
}
Output
Enter any number: 8
8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80
