C language question! I think you wrote the code correctly.

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

#include <stdio.h>

int main(void)
{
    int a, b;
    int result;

    printf("What is the value of a?" ");
    scanf_s("%d", &a);

    printf (What is the value of b? ");
    scanf_s("%d", &b);

    result = a * b;

    printf("%d * %d = %d", a, b, result);
}

It doesn't look like a problem Why does entering the value of a and the value of b turn off the execution immediately?

The value of the result should be printed out too, right?

c

2022-09-20 11:01

1 Answers

They wait because they need a user's input, but I think it's because the program ended as soon as it was printed out. You can stop the program temporarily by running the following immediately after the output syntax:

system("pause");


2022-09-20 11:01

If you have any answers or tips


© 2022 pinfo. All rights reserved.