Object

Write a program to print the table of a given number.

Algorithm

  1. Declare integer variables num and i.
  2. Read num.
  3. Set i = 1.
  4. DO
    • Write num*i.
    • i++.
    • WHILE i <= 10.
    • [End of DO-WHILE loop.]
  5. Exit.

Flowchart

C++ Source Code

// program 67
#include<iostream>
using namespace std;

int main()
{
  int num;

  cout << "Enter any number: ";
  cin >> num;

  int i = 1;
  do
  {
    cout << "\n" << num << " * " << i << " = " << num * i;
    i++;
  } 
  while (i <= 10);

  return 0;
}

C Source Code

/*program 67*/
#include<stdio.h>

int main()
{
  int num, i;
  printf("Enter any number: ");
  scanf("%d", &num);
  i = 1;
  do
   {
   printf("\n%d * %d = %d", num, i, num*i);
   i++;
   }
  while(i<=10);
  
  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

Design a site like this with WordPress.com
Get started