compiler used: dev-c++ 4.9.9.2
operating system: xp business
problem: program windown disapearing off screen half way through progam
Ive written a program where I take two variables (int&) and switch them. In the program i have the person enter the two variables.Then the program is suppose to switch them around.
I compiled the program and the compiler said......DONE....which means that the program is fine.
I hit run.
the program asks me for two numbers, I give it two numbers
right after i give the second number, I hit enter and then the whole program disapears off the screen
i put cin.get(); just befor the final return to keep the window open and to let the program run
it failed, same result.
When I was in college this last september i had the same problem.
I had a project to do and it was about creating a program that had three groups of people (adult,teens, infants)for an amusement park fee, in each catagory i was to write a sperate program and then bring all three programs together in one big program.
I never got past creating the three individual program
in each program the screen would disapear half way through the program.
I was absolutely baffled and the teacher couldnt figure it out.
the problem occurs specificially right at the point where all entries have been put in and the part of the program where its suppose to figure evverything out from all the entries
This program and those three programs in college have something in common. they would all run long enough to put in the entries and then when the enter button was hit the whole screen would disapear.
Ive even seen this problem occur with programs that dont have any entries put in them and have the values of the variables all ready put in the program.
this problem occurs right at that point right after the entries have been put in and where the program is suppose to figure things out and give a final result.
I tried using pause but im n ot sue how good that would do. The compiler tells me to declare the pause and i dont know how to do that so I removed the pause and left in the cin.get();
here is the program
I compiled it and the compiler said, DONE, which tells me that the compiler is telling me the program is fine. Besides that, when i run the program im at least able to enter the entries.
#include<iostream>
using namespace std;
void function(int& x, int& y);
void swap_values(int& x,int&y);
int number_1;
int number_2;
int main()
{
{
int a,b;
cout<<"enter two numbers please";
cout<<"first number:";
cin>>number_1;
cout<<"second number:";
cin>>number_2
a=number_1;
b=number_2;
swap_values(a,b);
cout<<"number_1<<number_2;
return
}
}
void swap_values(int& x,int& y)
{
int temp;
tem=x;
x=y;
y=temp;
return;
}
thank you