//please provide code for multiplication table
//please provide code for multiplication table
Anna
Please provide your code attempts before we offer help.
Try not.
Do or do not.
There is no try.
- Master Yoda
CODE
//multiplication table for the number 0<=10
#include <stdio.h>
int main()
int num, product;
for( num = 0; num<=10: num++ ) {
for( product = 1;
product = 0 * num);
}
printf( "product is %d/n", product);
return 0;
}
/Code
Anna
Close.... have a look at this version which is based on your conventions:
... and check the link in my signature for notes on how to use code tags.Code:#include <stdio.h> int main(void) { int num, product; for( num = 0; num<=10; num++ ) { for( product = 0; product<=10; product++ ) printf( "product of %d * %d is %d\n", product, num, product * num); } return 0; }
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Thanks for your help -- but I need the mulitiplication table displayed in rows and columns.
Anna
... then simply change the existing printf() statement to output something suitable for a row, and add putchar('\n'); at the end of the outer loop to start a new line.Originally posted by Anna Lane
Thanks for your help -- but I need the mulitiplication table displayed in rows and columns.
You'll have to do this yourself... no point in me doing it for you, I already know how to code and don't want to spoil your learning experience
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
I'm new at this -- I've tried putting the rows and columns in printf but I continue to get errors; plus I'm not getting correct answers for my multiplication table. What am I doing wrong?
Anna
>What am I doing wrong?
Post your code+errors, and someone will help you. Don't forget to use code tags when doing so.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
You're not paying attention in class, or you didn't do your reading.What am I doing wrong?
Seriously, Hammer's right. If you give up this easily, you're never going to enjoy programming. It only gets more difficult.
//I need the multiplication table in rows and columns with answers. What's missing?
Code:/* #include <stdio.h> int main() { int num, product; for( num = 0; num<=10;num++ ) { for( product = 0; product<=10; product++) printf( "product of %d*%d is %d/n", product, num, product); } return 0; } */
Anna
Anna, Please don't start new threads with the same topic.
The printf() call in your code doesn't quite match my version, I suggest you double check it. (its not doing any multiplication)
I'll expand on what I said before about the loops:
- the inner loop will printf() a rows worth of data, so you must remove the newline character in your current code.
- on the outer loop, add a new statement to print out a newline character just after the inner loop has completed. The command for this would be putchar('\n');
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]