C program to generate a multiplication table
Prerequisites:
- Knowing the for loop in C programing language
- An idea about format specifiers in C
- Knowing the C programming operators
For loop in C:
For loop is a program statement in C language which allows code to be executed until a terminal condition is met. They can even repeat forever if the terminal condition is never met.
Syntax:
for(initialization; condition; increment/decrement)
{
statement-block;
}
Initialization is where the variable is assigned a initial value while executing the loop.
Condition literally means the terminal condition of the for loop which must be satisfied for the loop statements to be executed.
Increment/decrement is where the variable value is either increased or decreased according.(For example, i- -or i++)
Finally, when the condition is false, it exits the loop.
C programming operators:
In this program, we will be using a few of C language’s arithmetic operators. An arithmetic operator performs mathematical operations such as addition(+), subtraction(-), multiplication(*), division(/).. on numerical values (constants and variables).
Format specifiers in C:
The format specifiers are used in C for input and output purposes. The compiler can understand that what type of data is in a variable during taking input using the scanf() function and printing using printf() function.
Here, we use %d which represents a signed integer data type.
Code:
This program reads an integer input from the user and generates the multiplication tables up to the range required by the user.
Output:
To learn C and such courses: