pages

Friday, 9 April 2021

c-program to calculate the table of the any natural number in c-programming

 program to calculate the table of the any natural number in c-programming.

In this section. we will  looking for the table of the any natural number by entering the value of the number by the user.

Now, In this program user enter the value of natural number in variable n and the loop is iteration.


#include<stdio.h>
#include<conio.h>
main()
{
    int i,n,t=1;
    printf("enter a natural number for table");
    scanf("%d",&n);
    for(i=1;i<=10;i++)
    {
       t=i*n;
       printf("%d*%d=%d\n ",n ,i, t);
    }
    getch();
}

output:  
              - enter a natual number= 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


No comments:

Post a Comment