program messes up at one part

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
42
43
// Includes
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

// Main Function
int main()
{
	string name , address , city , state , major;
	int zipcode , phonenumber;

	cout << "This will display your personal information.\n\n";

	cout << "Enter name: ";
	getline(cin , name);
	cout << "Enter address: ";
	getline(cin , address);
	cout << "Enter city: ";
	getline(cin , city);
	cout << "Enter state: ";
	getline(cin , state);
	cout << "Enter college major(s): ";
	getline(cin , major);
	cout << "Enter zip code: ";
	cin >> zipcode;
	cout << "Enter phone number: ";
	cin >> phonenumber;

	cout << "\n\n";

	cout << "Your name is " << name << endl;
	cout << "Your live at " << address << ", " << city << ", " << state << ", " << zipcode << endl;
	cout << "Your phone number is " << phonenumber << endl;
	cout << "Your college major(s) is " << major << endl;

	cout << endl << "Press ENTER to exit...";
	cin.clear();
	cin.sync();
	cin.get();

	return 0;
}


Can anyone tell me why after i run the program does the phonenumber as a random - number, example

i input 7278567888

it outputs like -8488884888
Make these changes:

1
2
int zipcode;
long long int phonenumber;
ok thank you
Topic archived. No new replies allowed.