6 Replies - 32353 Views - Last Post: 13 December 2007 - 11:24 PM Rate Topic: -----

#1 BaltaX  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-December 07

multiplication table

Post icon  Posted 13 December 2007 - 04:22 AM

hi i need a help for my assignment that will display a multiplication table up to 10 or more, under the table will ask a no. to execute and the product will be hightlighted along the table.. so far i got this program.. thanx..


multiplication table

#include<stdio.h>
#include<conio.h>
void main(void)
{
int i,j;
int n, c;
clrscr();
printf(" ");
printf("Enter a size for your table:\n");
scanf("%d", &n);

for(i=0; i<=n; i++)
{
for(j=1; j<=n; j++)
printf("\t%d", i*j);
printf("\n");
}
printf("\t");
getch();
}


Is This A Good Question/Topic? 0
  • +

Replies To: multiplication table

#2 jjhaag  Icon User is offline

  • me editor am smartastic
  • member icon

Reputation: 48
  • View blog
  • Posts: 1,789
  • Joined: 18-September 07

Re: multiplication table

Posted 13 December 2007 - 04:47 AM

What problem are you having with the program? It appears that it should output the desired multiplication table. given the user's input. I'm not quite sure what you mean by "the product will be hightlighted along the table" - are you talking about printing out a fixed size table and "highlighting" a particular user-defined value within the table? Or are you refering to something else?

The only other problems that I can see are that the clrscr() and getch() calls are not standard C++, so your code is not portable - it won't compile on my system.
Was This Post Helpful? 0
  • +
  • -

#3 BaltaX  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-December 07

Re: multiplication table

Posted 13 December 2007 - 10:44 PM

View Postjjhaag, on 13 Dec, 2007 - 04:47 AM, said:

What problem are you having with the program? It appears that it should output the desired multiplication table. given the user's input. I'm not quite sure what you mean by "the product will be hightlighted along the table" - are you talking about printing out a fixed size table and "highlighting" a particular user-defined value within the table? Or are you refering to something else?

The only other problems that I can see are that the clrscr() and getch() calls are not standard C++, so your code is not portable - it won't compile on my system.


yup you're right, my output will look lyk this:
but it would be atleast 10 integers. this only an example.
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15

enter a no. to be multiplied: 2x2 = 4

the 4 will highlight in the table.

thanks... :crazy:
Was This Post Helpful? 0
  • +
  • -

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 421
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: multiplication table

Posted 13 December 2007 - 10:51 PM

Please use :code: tags when posting code.
Was This Post Helpful? 0
  • +
  • -

#5 jjhaag  Icon User is offline

  • me editor am smartastic
  • member icon

Reputation: 48
  • View blog
  • Posts: 1,789
  • Joined: 18-September 07

Re: multiplication table

Posted 13 December 2007 - 10:52 PM

Well, I'd say that your best bet would be to highlight the value in the table as you print it out, using a conditional statement to test whether the current value that you're outputting is in the user's chosen row and column. A pseudocode for this (within your nested loops) would look something like this:
if row==chosen_row AND col==chosen_col
	print highlighted value
else
	print unhighlighted value
end if

The actual implementation won't be too much different from your original code, with the inclusion of an if-else control structure inside the nested for-loops. You'll have to decide what exactly you mean by highlighting. Text color? An asterisk by the appropriate value?

This post has been edited by jjhaag: 13 December 2007 - 10:52 PM

Was This Post Helpful? 0
  • +
  • -

#6 BaltaX  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-December 07

Re: multiplication table

Posted 13 December 2007 - 11:11 PM

View Postjjhaag, on 13 Dec, 2007 - 10:52 PM, said:

Well, I'd say that your best bet would be to highlight the value in the table as you print it out, using a conditional statement to test whether the current value that you're outputting is in the user's chosen row and column. A pseudocode for this (within your nested loops) would look something like this:
if row==chosen_row AND col==chosen_col
	print highlighted value
else
	print unhighlighted value
end if

The actual implementation won't be too much different from your original code, with the inclusion of an if-else control structure inside the nested for-loops. You'll have to decide what exactly you mean by highlighting. Text color? An asterisk by the appropriate value?

i still dont get it, hehehe, sorry, but can you made me a multiplication table by your own code, using turbo c and il try to copy that code, it prints a no. and can do the mutiplication..
Was This Post Helpful? 0
  • +
  • -

#7 jjhaag  Icon User is offline

  • me editor am smartastic
  • member icon

Reputation: 48
  • View blog
  • Posts: 1,789
  • Joined: 18-September 07

Re: multiplication table

Posted 13 December 2007 - 11:24 PM

There is a standing policy on this forum that we won't do other member's work for them.

You've already got the code to print a multiplication table. Now, you need to add some code to accept the two numbers that you'd like to multiply. Then, once you've decided exactly what you mean by "highlight", print the table, "highlighting" the value in the appropriate row and column (the row and column that the user has entered).

If you can be a little more clear about what you're having problems with, it will probably be easier for us to point you in the right direction.

This post has been edited by jjhaag: 13 December 2007 - 11:24 PM

Was This Post Helpful? 1

Page 1 of 1