« previous ProgramNext routine »

In this tutorial, you will learn and also get code about printing the table in adhering to ways:

Print Table of a given NumberPrint Table native 1 to 10Print Table of all numbers in offered Range

## C publish Table of a provided Number

To print the table of any number in C programming, you have to ask indigenous user come enter any number. Climate multiply the number through 1 come 10 and display the multiplication result at the time of multiplying the number through 1, 2, 3, ...., 9, 10 as presented here in the program offered below.

The question is, compose a regime in C come receive any number from user (at run-time) and also print that is table.Here is the prize of this question:

You are watching: How to make a table in c++

#include#includeint main() int num, i, tab; printf(\"Enter the number: \"); scanf(\"%d\", &num); printf(\"\\nTable of %d is:\\n\", num); for(i=1; iprintf(\"%d * %2d = %2d\\n\", num, i, tab); getch(); return 0;}
As the regimen was composed under Code::Blocks IDE, because of this after effective build and also run, friend will get the complying with output: Supply any number say 5 and press ENTER an essential to view the table of 5 as given in the second snapshot of the sample run: Program ExplainedReceive any type of number together input to speak 5 to publish the table the 5Inside the for loop, multiply the number v the worth of i and also initialize that to an additional variable speak tabThen print the value of tab as calculation each and also every time after ~ multiplication and initialization inside the for loopHere at first time, i hold 1 and then tab will host num*i or 5*1 or 5At 2nd time, i stop 2 and then tab will host num*i or 5*2 or 10In this way tab will hold, 5, 10, 15, ..., 45, 50

## C print Table native 1 to 10

This routine will publish table indigenous 1 to 10:

#include#includeint main() int num=1, res, i, j; printf(\"\\t\\tTable from 1 to 10\\n\\n\"); for(i=0; iprintf(\"Table the %d = \", num); for(j=1; jprintf(\"%d \", res); printf(\"\\n\"); num++; } getch(); return 0;} ## C publish Table in given Range

Let\"s create one more program the will additionally print the table the number. However this time, the program will questioning to get in the selection (starting and also ending number). The table of all the numbers that comes in in between these two offered numbers (including both), will certainly gets printed as output:

#include#includeint main() int n1, n2, i, j; printf(\"Enter the worth of n1 (starting point): \"); scanf(\"%d\", &n1); printf(\"Enter the worth of n2 (ending point): \"); scanf(\"%d\", &n2); for(i=n1; iprintf(\"Table that %d:\\n\", i); for(j=1; jprintf(\"%d x %d = %d\\n\", i, j, i*j); printf(\"\\n\"); } getch(); return 0;}

See more: Have Yourself A Merry Little Christmas Fingerstyle Tab By Ted Greene Now supply any two number to speak 2 and 3 as starting and ending allude and press get in to check out the output. The output will certainly be the table the 2 and also 3: