0

include

include

int mult_two_ints (int a , int b);

    int main(void)
    {
        printf("Choose an integer: ");
        int x = get_int( );
        printf("Choose another integer: ");
        int y = get_int( );

        int z = mult_two_ints (x , y);

        printf("The product of %i and %i is i%!\n", x , y , z);

    }

int mult_two_ints (int a , int b)
    {
    int product = a * b ;
    return product;
    }
1
  • The error occurs near the end and its pointing to the \n and saying its an invalid conversion specifier, what can i do to make this work?
    – Aina Hazel
    Jan 17 '18 at 7:01
1

Look at the placeholders in this line:

printf("The product of %i and %i is i%!\n", x , y , z);

%i is valid, but i% is a typo.

(The compiler is interpreting this as a literal "i" followed by the invalid identifier "%!".)

When this was compiled, it generated an error. The error pointed at the spot in the line that was bad. One of the things that you should get used to is to look at exactly what these errors are and where it is indicated in the line of code. At this point, typos and syntax will be a lot of the problems. As you get used to writing code, the syntax errors will be less and less, but logic problems will be the bigger issues.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • thank you!!!!!!!
    – Aina Hazel
    Jan 17 '18 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .