How to print tables in c language?

  c program to print tables

In this aticle you will learn who to print tables in c programming language with the help of for loop





code:-
==============================
int main()
{
    int num=7,tab;
    for (int i=1; i<=10; i=i+1) {
        tab=i*num;
        printf("%d*%d=%d\n",num,i,tab);
    }

    return 0;
}
==============================
output:-




Printing table with the help of user input:-
------------------------------------------------------

#include <stdio.h>

int main()
{
    int num,i,tab;// declare a variable 
    printf("Enter the digit:-");
    scanf("%d",&num);// take a positive number from the user

    printf("\nTable of %d is:\n", num);
     // use for loop to iterate the number from 1 to 10 
    for (int i=1; i<=10; i=i+1) {
        tab=i*num;
        printf("%d*%d=%d\n",num,i,tab);
    }
    return 0;
}
----------------------------------------------------------------------------
output:-


Comments