answersLogoWhite

0


Best Answer

void printTable() {

// pre-print column headers
printf(" ");
int c;
for (c = 0; c <= 10; ++c) {
printf("%4d", c);

}
printf("\n");

printf(" ");
for (c = 0; c <= 10; ++c) {
printf(" -");

}
printf("\n");

// calculations
int r;
for (r = 0; r <= 10; ++r) {

// row headers
printf("%2d|", r);

// calculation for the current row
for (c = 0; c <= 10; ++c) {

printf("%4d", (r * c));

}
printf("\n");


}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

#include<stdio.h>

#include<conio.h>

void main()

{

int n,p,i;

printf("\n enter the noof which u want to see the table");

scanf("%d",&n);

for(i=1;i<=10;i++)

{

p=n*i;

printf("\n%d *%d=%d",n,i,p);

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

#include

#include

main()

{

int s,k,mul;

clrscr();

for(s=0;s<=12;s++)

{

for(k=0;k<=10;k++)

mul=s*k;

}

printf("the table for 1 to 12 no. is%d",mul);

getch();

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

#include<iostream>

#include<iomanip>

int main()

{

using namespace std;

int r,c;

cout<<"Multiplication Table\n\n"<<setw(4)<<"";

for(c=1; c<=12; ++c )

cout<<setw(4)<<c;

cout<<endl;

for(r=1; r<=12; ++r )

{

cout<<setw(4)<<r;

for(c=1; c<=12; ++c )

cout<<setw(4)<<r*c;

cout<<endl;

}

cout<<endl;

return(0);

}

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

#include<iostream>

#include<iomanip>

using std::cout; // std out

using std::endl; // newline and flush

using std::setw; // set width

int main()

{

// the largest value is 144 (12*12) which has 3 digits

// thus each value requires a minimum width of 4 columns

unsigned width=4;

// loop control variables

unsigned row, column;

// display the table title

cout<<"Multiplication Table\n"<<endl;

// display the column header

cout<<setw(width)<<'|';

for (column=1; column<=12; ++column)

cout<<setw(width)<<column;

cout<<endl;

// underline the column header

for (column=0; column<=12; ++column)

cout<<setw(width)<<"----";

cout<<endl;

// loop through each row

for (row=1; row<=12; ++row)

{

// display the row header

cout<<setw(width-1)<<row<<'|';

// loop through each column and

// display the row and column products

for (column=1; column<=12; ++column)

cout<<setw(width)<<row*column;

cout<<endl;

}

cout<<endl;

}

Output:

Multiplication Table

| 1 2 3 4 5 6 7 8 9 10 11 12

----------------------------------------------------

1| 1 2 3 4 5 6 7 8 9 10 11 12

2| 2 4 6 8 10 12 14 16 18 20 22 24

3| 3 6 9 12 15 18 21 24 27 30 33 36

4| 4 8 12 16 20 24 28 32 36 40 44 48

5| 5 10 15 20 25 30 35 40 45 50 55 60

6| 6 12 18 24 30 36 42 48 54 60 66 72

7| 7 14 21 28 35 42 49 56 63 70 77 84

8| 8 16 24 32 40 48 56 64 72 80 88 96

9| 9 18 27 36 45 54 63 72 81 90 99 108

10| 10 20 30 40 50 60 70 80 90 100 110 120

11| 11 22 33 44 55 66 77 88 99 110 121 132

12| 12 24 36 48 60 72 84 96 108 120 132 144

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

#include<stdio.h>int main (void) {

int row, column;

for (column=1; column<=12; ++column) {

printf ("\t%d", column);

}

printf ("\n");

for (row=1; row<=12; ++row ) {

printf ("%d", row);

for (column=1; column<=12; ++column) {

printf ("%d\t", row*column);

}

printf ("\n");

}

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

There are many ways to solve this problem. You can use different algorithms to fix this. But you may want to try this algorithm. It works for me.

  1. Declare and define the main function.
  2. Declare 4 variables. The first variable is for the number of digits to be multiplied, the second variable is the total of the two numbers multiplied. The third and fourth variable is used as a loop counter and the multipliers and multiplicands in our multiplication.
  3. Ask the user to input how many numbers does the multiplication table will include.
  4. Since the C console will print data in a linear way, using a for loop, print the columns to be multiplied on the column.
  5. After printing the rows, declare another separate for loop. Print the multiplicand value by printing the counter of that for loop.
  6. Add a nested for loop. This will serve as the multiplier. Multiply the counter of the first for loop to the counter of the nested for loop. Print the results.

Here is a sample code:

#include

#include


int main (int argc, char *argv[])

{

int numbers = 0;

int total = 0;

int counter = 0, counter2 = 0;


printf ("Type the numbers that will be printed in multiplication table: ");

scanf ("%d", &numbers); // ask user how many numbers to include

printf ("\nMultiplication Table: 1 to %d\n\n", numbers);


for (counter = 1; counter <= numbers; counter++) { // type the number of columns

printf ("\t%d", counter);

}

printf ("\n");


for (counter = 1; counter <= numbers; counter++) {

printf ("\n%d", counter);

for (counter2 = 1; counter2 <= numbers; counter2++) {

total = counter * counter2; // multiply the multiplier times the multiplicand

printf ("\t%d", total); // print the total

}

}


return (0);

} // main

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

write a c program that prints out the multiplication table of 4 using function

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

for (unsigned i=1; i!=100; ++i)

std::cout << "2 x " << i << " = " << i*2 << std::endl;

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

std::cout << "Enter a whole number: ";std::cin >> num;

for (unsigned x=1; x<=12; ++x) std::cout << x*num << ',';

std::cout<<std::endl;

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you Write a program in c plus plus to display the multiplication table?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How Write javascript program to display multiplication table of 2 without accepting input from user?

Use a counted for loop. On each iteration, multiply the control variable by 2 and print the result.


Write a program in vbscript to display a multiplication table in web page?

Option explicit Dim val,indx val=inputbox("enter any number") For indx= 1 to 10 print val&amp;"*"&amp;indx&amp;"="&amp;val&amp;"*"indx Next


How do you write multiplication table program in php?

// example of 1..12x12 table for($i = 1; $i &lt;= 12; $i++) { for($j = 1; $j &lt;= 12; $j++) { print ($i * $j) ." "; } print "\n"; }


Write a program to display a table of 5?

#include &lt;stdio.h&gt; #include&lt;conio&gt; void main () {int a,i:, printf("\n The Multiplication table of 5 is n"):, For(i=1;i=20;i++) Printf("%d",a*i); getch(); }


How do you write program c of table 5?

#include#includevoid main(){ int a,i;printf("\nThe Multiplication table of 5 is:\n");for(i=1;i


Write an Algorithm for multiplication table of an integer?

int firstNumber,secondNumber for(firstNumber = min; firstNumber &lt;= max; firstNumber++); { for(secondNumber = min; secondNumber &lt;=max; secondNumber++); int result firstNumber * secondNumber; }


How do you make a program in python using do while loop to display the multiplication table of number from one to ten?

a = 0while a < 10 :a += 1print (a)Write the above simple script in a text editor (I use nano). Save as loop.py in home folder. To run, open a terminal and at the prompt, write: python loop.pyResult:rodney@downstairs:~$ python loop.py12345678910


Write a Unix program that generates a multiplication table?

$vi multable.sh echo "enter the value of n:" read n i=1 for((i=1;i&lt;=10;i++)) do echo " $n * $i = `expr $n \* $i`" done


Program to display multiplication table for given number?

#include&lt;stdio.h&gt; main() { int i,n; clrscr(); printf("enter the value"); scanf("%d", &amp;n); while(i&lt;=10) { printf("\n %d*%d=%d",n,i,(i*n)); i++; } getch(); }


Where can I find a multiplication table printable?

http://www.mathsisfun.com/multiplication-table-bw.html this is a printable multiplication table. Multiplication doesn't change no matter what grade so just leave the chart as is.


Write a program to display table of five in unix?

sum=0 i=1 echo "Enter any number " read num while [ $i -le 10 ] do sum=`expr $num \* $i` i=`expr $i + 1` echo "Table of a number is " $sum done


Write a java program to draw a multiplication table?

class table{public static void main(String args[])int n=2;System.out.println("Table of " + n + " is :");int result;for (int a = 1; a