Introduction: In this article i will explain with example
program to print table of any entered number using for loop in C Language.
In previous article i explained What is For loop in C language? Program to print counting up to given limit and What is goto statement in C language,its advantages and disadvantages with program example and Program to calculate sum,average and division of marks using else-if ladder in C Language and Swap two numbers without using temporary variable and Find greatest of three numbers using nested if else statement .
Implementation: Let's create a program to print table.
#include<conio.h>
#include<stdio.h>
void main()
{
int num,i,table=0;
clrscr();
printf("Enter any number: ");
scanf("%d",&num);
for(i=1;i<=10;i++)
{
table=num*i;
printf("%d * %d = %d\n",num,i,table);
}
getch();
}
- Run the program using Ctrl+F9
Output:
Enter any number: 5
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
Now over to you:
"If you like my work; you can appreciate by leaving your comments,
hitting Facebook like button, following on Google+, Twitter, Linked in and
Pinterest, stumbling my posts on stumble upon and subscribing for receiving
free updates directly to your inbox . Stay tuned and stay connected for more
technical updates."
If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..