Hey,
I'm learning C Programming at Uni and was given the following code to compile and try the program...
Code:
#include <stdio.h>
main()
{
int pets;
int cats;
int dogs;
printf("\a How many pets do you have?\n");
scanf("%d", &pets);
printf("So, you have %d pets! How many of these are cats?\n", pets); scanf("%d", &cats);
printf("and how many dogs?\n", dogs);
scanf("%d", &dogs);
printf("So, you have %d pets of which %d are cats and %d dogs!\n", pets, cats, dogs);
return 0;
}
Can someone explain why the window is closing before the final line is printed and how I stop this?
Thank you for your time,
Scott