Help how do I declare variable correctly?

Also what's the difference between string and int?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 #include <iostream>

using namespace std;

int main()

{
	int Bounty; 
	string firstName;
	double rate;
	Bounty =  4000000000;
	rate = 0.2 * 0.3;
	firstName = "Monkey";
	int age = 19;
	string middleName, lastName;
	middleName = "D.";
	lastName = "Luffy";

	cout << "His name is" << firstName << " "
		 << middleName << " " << lastName << endl;
	cout << "He has" << Bounty << " " <<  "Belly on his head " << endl;
	cout << "And he is only" << age << "years old." << endl;
}   
Last edited on
int is a fundamental integer type. std::string is a compound user-defined class.

As for your code then you have to include header <string> if you are using objects of type std:;string.
Last edited on
closed account (z05DSL3A)
Noct,

Start here:
http://www.cplusplus.com/doc/tutorial/variables/
Topic archived. No new replies allowed.