Click here to Skip to main content
14,929,103 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#include <stdio.h>
int main() 
    char n, i;
    printf("Enter an integer:");
    scanf("%d", &n);
    for (i = 1; i <= 10; ++i) 
        printf("%d * %d = %d \n", n, i, n, n * i);
    return 0;

What I have tried:

I think the issue is with the math
Updated 6-May-21 4:38am

We can't tell you: we have no idea what that code is meant to do, and since the "math" is so basic it's unlikely to be that.

But ... why do you specify three output values in the format string "%d * %d = %d \n" and provide four output values in the parameter list: n, i, n, n * i
n is in there twice ...
Imaginary Toast 6-May-21 10:15am
Oh that's where my problem is. Thanks.

Is this better?

#include <stdio.h>
int main() {
int n, i;
printf("Enter an integer: ");
scanf("%d", &n);
for (i = 1; i <= 10; ++i) {
printf("%d * %d = %d \n", n, i, n * i);
return 0;
OriginalGriff 6-May-21 10:27am
Could be.

Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. So we have no idea what your code is meant to do unless you tell us ...
Imaginary Toast 6-May-21 10:32am
Sure, I'll tell you. So, this code basically sets up a multiplication table, with answer, like you enter 3, it writes 3 x 1 = answer, 3 x 2 = answer, 3 x 14 = answer, and so on.
Dave Kreskowiak 6-May-21 13:58pm
What happened when you TRIED IT?
very simple you need to change:
int n, i;
and remove the third parameter in your print.

Be more careful in writing and reading code ;-)
Imaginary Toast 6-May-21 10:39am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900