im trying to teach my self c++ from a book and it has several activities.
i compile it fine but when i run it, it runs disappears and stays running.
#include <iostream>
int add(int x, int y)
{
return (x+y);
}
int main()
{
typedef unsigned short US;
typedef const unsigned short CUS;
US score = 0;
CUS TOUCH = 6;
CUS FELD = 3;
CUS EXTRA = 1;
CUS SAFETY = 2;
std::cout << "our team scores a touchdown!\n";
std::cout << "we now have" << add(TOUCH, score) << "points!\n";
std::cout << "our team scores a feald goal!\n";
std::cout << "we now have" << add(FELD, score) << "points!\n";
std::cout << "our team scores an extra point!\n";
std::cout << "we now have" << add(EXTRA, score) << "points!\n";
std::cout << "our team scores a safety point\n";
std::cout << "we now have" << add(SAFETY, score) << "points!\n";
std::cout << "THE GAME IS NOW OVER! WE HAVE" << score << "points!\n";
return 0;
}
People are against system("pause") if it is included in the actual code. If getch() cannot work, you can write a simple batch file and put it into your executable directory. Namely, I don't think this is trouble: