Simple code isn't compiling

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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  #include <iostream>
using namespace 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;
}
Last edited on
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
 
int nextStep();
on line 3.
for newbie like me, just waiting for mastah answere heheh
@mobozzi Ah, thank you! That makes sense.
@mbahmimpi Hahaha
Registered users can post here. Sign in or register to post.