-->
Showing posts with label program to display multiplication table of numbers using nested loop.. Show all posts
Showing posts with label program to display multiplication table of numbers using nested loop.. Show all posts

program to display multiplication table of a number .

//program to display multiplication table of a number .
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n;
printf("enter value of 'n'(as a number)\n");
scanf("%d",&n);
while(k<=10)
   {
      printf("%d*%d=%d\n",n,k,n*k);
      k++;
   }
getch();
}
-------------------------------- note:
1)You can directly print instead given format.
put
printf("%d\n",n*k);

2) you can use nested loop for this as well.
 like
for(i=1;i<=1;i++)
  {
    for(k=1;k<=10;k++)
      {
          printf("%d\n",i*k);
       }
   }
you can put i =n if you enter this.
------------------------------------------------------------------------------
let's see the program using nested loop
//program to display multiplication table of a number using nested loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
printf("enter value of 'n'(a number for multiplication table)\n");
scanf("%d",&n);
for(i=n;i<=n;i++)
  {
    for(k=1;k<=10;k++)
      {
          printf("%d\n",i*k);
       }
          printf("\n");
   }
getch();
}
-----------------------------------------------------------------------------------------
let's see the program to get multiplication table of numbers using nested loop
//program to display multiplication table of  numbers using nested loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
printf("for how many numbers, you want t o go for multiplication table\n");
scanf("%d",&n);                       // from 1 to n
for(i=1;i<=n;i++)
  {
    for(k=1;k<=10;k++)
      {
          printf("%d\n",i*k);
       }
          printf("\n");
   }
getch();

}