A multiplication table, also known as a times table, is a mathematical table used to define a multiplication operation for an algebraic system. In the context of basic arithmetic, a multiplication table shows the results of multiplying two numbers from 1 to a specific value.
Example:
Multiplication Table of 4: 4 x 1 = 4 4 x 2 = 8 4 x 3 = 12 4 x 4 = 16 4 x 5 = 20 4 x 6 = 24 4 x 7 = 28 4 x 8 = 32 4 x 9 = 36 4 x 10 = 40
Problem Statement.
Write a C program to generate any multiplication table for a given number (up to a specified limit) and display the table in a formatted manner.
Steps to Generate the Multiplication Table:
Step 1: Input the number for which you want to generate the multiplication table (let's call it 'num').
Step 2: Input the limit up to which you want to generate the table (let's call it 'limit').
Step 3: Use a loop to iterate from 1 to 'limit'.
Step 4: Inside the loop, calculate the product of 'num' and the loop variable and display the result in a formatted manner.
C Program to Generate Multiplication Table of Any Number.
//C program to print multiplication table of a number #include <stdio.h> int main() { int num, limit; printf("Enter the number for multiplication table: "); scanf("%d", &num); printf("Enter the limit for the table: "); scanf("%d", &limit); //Generate and display the table printf("Multiplication table for %d up to %d:\n", num, limit); for (int i = 1; i <= limit; i++) { printf("%d x %d = %d\n", num, i, num * i); } return 0; }
Enter the number for multiplication table: 6
Enter the limit for the table: 10
Multiplication table for 6 up to 10:
6 x 1 = 6
6 x 2 = 12
6 x 3 = 18
6 x 4 = 24
6 x 5 = 30
6 x 6 = 36
6 x 7 = 42
6 x 8 = 48
6 x 9 = 54
6 x 10 = 60
No comments:
Post a Comment