-
Simple program
Code:
#include <iostream>
using namespace std;
int main()
{
int apples, oranges; //Declares the variables apples and oranges
int fruit;
apples = 5; oranges = 6;
fruits = apples + oranges;
cout << endl; //Starts a new line
cout << "Oranges are not the only fruit... " << endl
<< "- and we have " << fruit << " fruits in all.";
cout << endl; // Start output on a new line
return 0;
}
I got that out of a tutorial and I ran it in VC++ 6 and it came up with an error. I checked through it over and over but it isnt coming up right. Whats wrong with it?
-
Don't see any problems right off. Whats the error you're getting?
-
Very simple mistake, you added an 's' to to the variable "fruit" in the line fruit = apples + oranges;
here ya go:
Code:
#include <iostream>
using namespace std;
int main()
{
int apples, oranges; //Declares the variables apples and oranges
int fruit;
apples = 5; oranges = 6;
fruit = apples + oranges;
cout << endl; //Starts a new line
cout << "Oranges are not the only fruit... " << endl
<< "- and we have " << fruit << " fruits in all.";
cout << endl; // Start output on a new line
return 0;
}
-
oops. Well that was odvious. Thanks for the help!