multiplication table in c

Multiplication Table in C

Here's a simple C program to generate a multiplication table. This program will prompt the user to enter a number and then display the multiplication table for that number from 1 to 10.

#include <stdio.h>

int main() {
    int num, i;

    printf("Enter a number: ");
    scanf("%d", &num);

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

    return 0;
}

Explanation of the steps: 1. Include Header File: The program starts by including the standard input-output header file stdio.h to enable input and output operations.

  1. Main Function: The main function is the entry point of the program.

  2. Variable Declaration: Inside the main function, two variables are declared: num to store the user input and i for the loop iteration.

  3. User Input: The program prompts the user to enter a number using printf and reads the input using scanf.

  4. Multiplication Table: A for loop is used to iterate from 1 to 10. Within the loop, the program prints the multiplication table for the entered number using the format specifier %d to display the values.

  5. Return Statement: Finally, the main function returns 0 to indicate successful execution.

This program demonstrates a basic implementation of a multiplication table in C.

[[SOURCE 8]]