I'm a newbie C programmer, but I have worked with Visual Basic and did a little (3-4 days) of a C++ coding book. Currently I am opening my C coding book (with I also only did 3-4 days of last time) to learn to code in C. I hope to gain an understanding of programing so that I can start working on simple, text-based games and then later on, maybe something with graphics. Anyway, on to my question:
I am using the Miracle C compiler for my work and have just finished a program that takes 2 numbers (supplied by the user) and multiplies them together. The problem is, after I enter the numbers the computer gets the answer and terminates the program. Obviously, this happens so fast that there isn't time to see the answer. (or to know if the answer is even comming out) What can I add in to my program that will tell the computer to wait for me to tell it to terminate? I've pasted my code below:
PHP Code:
/* Program to calculate the product of two numbers. */
#include <stdio.h>
int a,b,c;
int product(int x, int y);
int main()
{
/* Get the first number */
printf("Enter a number between 1 and 100: ");
scanf( "%d", &a);
/* Get the second number */
printf("Enter another number between 1 and 100: ");
scanf("%d", &b);
/* Calculate and display the product */
c = product(a, b);
printf ("%d times %d = %d\n", a, b, c);
return 0;
}
/* Function returns the product of the two values provided */
int product(int x, int y)
{
return (x * y);
}