
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Print Multiplication Table Using For Loop in C
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.
Algorithm
Given below is an algorithm to print multiplication table by using for loop in C language ?
Step 1: Enter a number to print table at runtime. Step 2: Read that number from keyboard. Step 3: Using for loop print number*I 10 times. // for(i=1; i<=10; i++) Step 4: Print num*I 10 times where i=0 to 10.
Example
Following is the C program for printing a multiplication table for a given number ?
#include <stdio.h> int main(){ int i, num; /* Input a number to print table */ printf("Enter number to print table: "); scanf("%d", &num); for(i=1; i<=10; i++){ printf("%d * %d = %d
", num, i, (num*i)); } return 0; }
Output
When the above program is executed, it produces the following result ?
Enter number to print table: 7 7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49 7 * 8 = 56 7 * 9 = 63 7 * 10 = 70
Advertisements