c program to print the multiplication table

#include <stdio.h>

int main() {
   int num, i;

   printf("Enter an integer: ");
   scanf("%d", &num);

   for (i = 1; i <= 10; ++i) {
      printf("%d  %d = %d\n", num, i, num  i);
   }

   return 0;
}

Explanation of the code:

  • The code starts by including the standard input/output library stdio.h, which provides functions like printf and scanf.
  • The main function is the entry point of the program.
  • It declares two variables: num to store the number entered by the user and i to iterate through the multiplication table.
  • The program prompts the user to enter an integer using printf and reads the input using scanf. The entered value is stored in the num variable.
  • The for loop is used to iterate from 1 to 10.
  • Inside the loop, the program uses printf to print the multiplication table, multiplying the entered number num with the current iteration value i.
  • The format specifier %d is used to print integers, and \n is used to print a new line after each multiplication line.
  • Finally, the return 0 statement is used to indicate successful termination of the program.

This program will take an integer input from the user and print its multiplication table from 1 to 10.