|
-
October 28th, 2009, 08:34 PM
#1
Window autocloses
Hello I am a student taking a c++ class and our first assignment is to make a program that takes 5 numbers and adds them
now i have a basic outline but when it adds and displays the answer the window closes any thoughts
#include "stdafx.h"
int
main(void)
{
char first, middle, last;
int number_1;
int number_2;
int number_3;
int number_4;
int number_5;
int total_numbers;
printf("Program Written By Ryan Kiesel\nLast Updated October 28-2009\n\n\n ");
printf("\nType your Initials> ");
scanf( "%c%c%c", &first, &middle, &last);
printf("\nPress a Number> ");
scanf( "%d", &number_1);
printf("\nPress a Number> ");
scanf( "%d", &number_2);
printf("\nPress a Number> ");
scanf( "%d", &number_3);
printf("\nPress a Number> ");
scanf( "%d", &number_4);
printf("\nPress a Number> ");
scanf( "%d", &number_5);
total_numbers = number_1 + number_2 + number_3 + number_4 + number_5;
printf("\n\n Thank you for your submission %c%c%C your total was: %d\n", first, middle, last, total_numbers);
return(0);
}
-
October 28th, 2009, 10:23 PM
#2
Re: Window autocloses
That is what happens when you run it from the IDE.
How do you want the program to wait for?
If you put getchar() before the return, it will wait till you press ENTER.
If you pet _getch() before the return, it will wait till you press any key.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|