Program to Print Table in C |Creating A Table Program| Print Table of any number| Table in C| Learning how to code
To Become a Good Programmer you should have basic knowledge of loops used in C, These Loops are For, while, do while. These loops are used to create high Level Programs. Loops are used to do or run a specific task n No of times. To Get comfortable with these loops you should have decent practice of using them.
Working Of Program
So today we are going to create a Program using Loop in C, We are going to write a program to print the table of a number. In This we will create 2 Integer of Value i and j. For Int i it will get the input of which no you want to print table of and j will be used to run loop till 10. In this we are going to use for loop which we will run till 10 and after 10 the loop will end.
After using this loop you will get the basic knowledge of how to use Loops in Programing language.
We will use printf and scanf operator in the program. printf is used to print the desired output in C and scanf is used to take input from the user. How these work, printf works command followed by the () and ; at the end. eg:- printf("Hello World!"); and scanf works as command followed by the (), in brackets(), we have to define in which type of input we have to take for eg: int, string, float etc which is done by ("%d") for Integer, ("%s") for String and ("%f"). These are called format specifier. For taking input in which declared data type integer/string/float we use (&) command is used followed by the name of the declared by the data type. This is how we fully declare it:- ("%d", &i").
Code for Printing Table:
//Program to Print Table of A Number #include<stdio.h> int main(){ int i,j,k; //Taking Input of the User printf("Enter the No of Which you want table of: "); scanf("%d",&i); for (j = 1; j <= 10; ++j) { printf("%d*%d=%d \n",i,j,i*j); } }
Output:
Enter the No of Which you want table of:5 //To print table of 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