Simple program

This is a discussion on Simple program within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> using namespace std; int main() { int apples, oranges; //Declares the variables apples and oranges int fruit; ...

  1. #1
    ___
    Join Date
    Jun 2003
    Posts
    806

    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?
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Don't see any problems right off. Whats the error you're getting?
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    81
    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;
    }

  4. #4
    ___
    Join Date
    Jun 2003
    Posts
    806
    oops. Well that was odvious. Thanks for the help!
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with a very simple program
    By htdefiant in forum C++ Programming
    Replies: 13
    Last Post: 08-14-2007, 02:27 PM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  3. [Help] Simple Array/Pointer Program
    By sandwater in forum C Programming
    Replies: 3
    Last Post: 03-30-2007, 03:42 PM
  4. simple silly program
    By verbity in forum C Programming
    Replies: 5
    Last Post: 12-19-2006, 06:06 PM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21