Using iostream in VS 2010

How do I using #include <iostream> in Visual Studios 2010? I used to know since I had to use the 2010 version in High School. But that was 3 years ago and I had been using 2013 version.
What problem are you having?
In the same way you do with VS2013
Is there something I have to type before the #include statements? Because I am getting errors.
Please show us the errors and possibly the code.
When you create the project, don't use any of the templates - choose Blank.

Here is the code that is generating errors.

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//Programmer's Name: Bolong Yu
//Program: Practice 
//Grade:
//Comments:
//
//-----------------------------------------------------------------------------
//Programmer's Name: Bolong Yu
//Program: Practice
//Program Flow (IPO):
//Output a header to the screen
//Assign the value for the quantity on hand
//Calculate the quantity to order
//Output the quantity to order
//Assign values for the 4 costs
//Calculate the total cost and the average cost
//Output the 4 costs and the total cost and 
//	the average cost to the screen
//Assign the first initial and last initial
//Output the first initial and last initial to the screen.
//Assign the first name and last name
//Output the first name and last name to the screen
//-----------------------------------------------------------------------------



//For input and output on the screen
#include <iostream>
//For using the string data type
#include <string>

using namespace std;

const int QUANTITY_REQUIRED = 200;
const int NUMBER_OF_ITEMS = 4;

const string COLLEGE = "SUNY Broome Community College";
const string MY_NAME = "Bolong Yu";


int main(void)
{
	int quantityOnHand;
	int quantityToOrder;

	double cost1;
	double cost2;
	double cost3;
	double cost4;
	double totalCost;
	double averageCost;

	char firstInitial;
	char lastInitial;

	string firstName;
	string lastName;

	//Output the programmer's name and College to the screen
	cout << "-----------------------------------------------------------------"
		<< endl;
	cout << COLLEGE << endl;
	cout << MY_NAME << endl;
	cout << "Output from the practice" << endl;
	cout << "-----------------------------------------------------------------"
		<< endl;

	//Assign the quantity on hand
	quantityOnHand = 66;

	//Calculate the quantity to order
	quantityToOrder = QUANTITY_REQUIRED - quantityOnHand;

	//Output quantity on hand and quantity to order to the screen
	cout << "The current quantity on hand is " << quantityOnHand << endl; 
	cout << "The quantity to order is " << quantityToOrder << endl;
	cout << "-----------------------------------------------------------------"
		<< endl;

	//Set the cost of the 4 purchases
	cost1 = 12.50;
	cost2 = 200.45;
	cost3 = 1200.39;
	cost4 = 39.99;

	//Calculate the total cost 
	totalCost = cost1 + cost2 + cost3 + cost4;

	//Calculate the average cost
	averageCost = totalCost / NUMBER_OF_ITEMS;

	//Output the costs of the 4 items to the screen
	cout << "Cost of Item 1 is " << cost1 << endl;
	cout << "Cost of Item 2 is " << cost2 << endl;
	cout << "Cost of Item 3 is " << cost3 << endl;
	cout << "Cost of Item 4 is " << cost4 << endl;
	cout << endl;

	//Output the total and average of the 4 items purchased to the screen.
	cout << "-----------------------------------------------------------------"
		<< endl;
	cout << "Total Cost is " << totalCost << endl;
	cout << "Average Cost is " << averageCost << endl;
	cout << "-----------------------------------------------------------------"
		<< endl;

	//Assign the first and last initial
	firstInitial = 'C';
	lastInitial = 'S';

	//Output the two initials to the screen
	cout << "The two initials are: " << firstInitial << '.'
		<< lastInitial << '.' << endl;
	cout << "-----------------------------------------------------------------"
		<< endl;

	//Assign the name
	firstName = "Bolong";
	lastName = "Yu";

	//Output the name to the screen
	cout << "The name is " << firstName << ' ' << lastName << endl;
	cout << "-----------------------------------------------------------------"
		<< endl;

	return 0;

}
There is no compilation error with the code; it compiles and runs:
http://ideone.com/BzCdO4

Try deleting your project and re-creating it as a blank or empty project.
Topic archived. No new replies allowed.