can someone help me jump back to the start of program (cout). The expected result should be: result printed --> Do you want to start again? (y/n). if answer = y then go to the start, if answer = n, then close the program.
Here's the code:
#include <iostream>
#include <string>
class myClass {
private:
int var[3];
char response;
public:
void input() {
std::cout << "Please enter a number " << std::endl;
std::cin >> var[0];
std::cout << "Please enter a range " << std::endl;
std::cin >> var[1];
}
void calc() {
for (var[2] = 1; var[2] <= var[1]; var[2]++)
std::cout << var[2] * var[1] << std::endl;
}
};
int main() {
myClass MyObj;
MyObj.input();
MyObj.calc();
system("pause");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire