Hey y'all, this simple code I've been working on isn't running on visual studio. I'm not sure why, although it stopped working after I attempted the for loop. Thanks!
#include <iostream>
usingnamespace std;
int main()
{
string name;
int age;
string country;
int answerOneNoYes;
std::cout << "Please enter your name: \n"; // asks user for their name
std::cin >> name; // stores their name
std::cout << "Hello " << name << "!" << std::endl; // greets user with stored name
std::cout << "Please enter your age: \n"; // asks the user for their age
std::cin >> age; // stores their age
std::cout << "Lastly, enter your country: \n"; // asks the user for their country
std::cin >> country; // stores their country
// concludes a message with all of the stored info & asks the user for verification
std::cout << "Thanks for the info.\n" << "Your name is " << name << ", you're from " << country << ", and you're " << age << " years old. Is that correct? Type '1' for yes or '0' for no.\n";
std::cin >> answerOneNoYes;
if (answerOneNoYes == 1) // determines if yes or no was said | 1 = yes, 0 = no
{
nextStep(); // if yes, calls nextStep() and continues the process
}
else
{
std::cout << "Please exit the program and try again.\n"; // otherwise, user is given this message prompting to restart the program
}
return 0;
}
int nextStep()
{
std::cout << "You've completed the first step.\n";
return 0;
}
1. #include <string> is missing
2. the name nextStep is used before it's declared. Declare the function before its point of use, for example, by placing