473,433 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,433 software developers and data experts.

Two compiling errors

6
Can you please tell me what i am missing? I get two errors when i compile.

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include
  3. <iostream> using namespace std;
  4. int main()
  5. {
  6. double num_one, num_two, num_three, num_four, num_five, num_six, num_seven, num_eight, sum, product, average;char ans ;
  7.  
  8. cout << "Please enter eight numbers: "<< endl; 
  9. cin >> num_one >> num_two >> num_three >> num_four>> num_five >> num_six >> num_seven >> num_eight;
  10.  
  11. cout << "The sum of the numbers is: " << endl;sum =num_one + num_two + num_three + num_four + num_five+ num_six + num_seven + num_eight;
  12. cout << sum << endl;
  13.  
  14. cout << "The product of the numbers is: " << endl;
  15.  
  16. product = num_one * num_two * num_three * num_four * num_five * num_six * num_seven * num_eight;cout << product << endl;
  17.  
  18. cout << "The average of the numbers is: " << endl;
  19. average = (num_one + num_two + num_three + num_four + num_five + num_six + num_seven + num_eight)/8;
  20. cout << average << endl;
  21. return 0
  22. }
  23.  
Dec 4 '08 #1
6 1684
vmpstr
63
You are missing a semicolon after return 0. Also, for the future: it would be extremely helpful if you, aside from posting your code, also post the error you get.

Typically, we are much better at understanding the error message than we are at just skimming the code and figuring out what's wrong.

good luck! :D
Dec 4 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
Also, your using namespace std is on the same line as #include<iostream>.

All those lines starting with # are preprocessor directives. Everything on that line must apply to that directive.
Dec 4 '08 #3
whodgson
542 512MB
Also you need to pause the output screen so you can read the output by, for example, writing system("pause");before return 0;...... although I`m not sure the experts would agree with this method
Dec 9 '08 #4
Ganon11
3,652 Expert 2GB
@whodgson
It really depends on several things. When I am using a command line compiler like g++, I don't need the system("pause") command at the end, since I can just view the output in the command prompt after the program runs. When I use the IDE Dev C++, I need to use that line, because otherwise the window disappears (I've been told running in the non-Debugging mode fixes this, but I've done it in non-Debug mode, and it still doesn't work).

Regardless, don't just blindly put in system("pause") at the end of your program. Doing so means it will only work in environments where "pause" is a valid shell command (as far as I know, Windows has it, Linux does not). There are other ways to simulate the same effect without forcing an OS dependency, such as manually using cin.get() to force the user to type in a character before the program terminates.

The bottom line is this: you don't always need to pause the screen, and when you do, be aware that your method may limit the portability of your code.
Dec 9 '08 #5
Banfa
9,065 Expert Mod 8TB
If may also limit the usability of your code, for instance if the program is meant to be used in an automated process (an overnight build say) then pausing at the end waiting for user input is the last thing you want to be doing.
Dec 9 '08 #6
JosAH
11,448 Expert 8TB
w.r.t. the original problem: what would the OP have done if, say, hundred numbers, or thousand of them, had to be processed?

kind regards,

Jos
Dec 9 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Andres Rosado-Sepulveda | last post by:
Hello, I'm having trouble compiling PHP 4.3.4 on Solaris 8. This is the error message it is showing: -- start -- Undefined first referenced symbol ...
0
by: yzzzzz | last post by:
Hi, I am compiling PHP 5.0.2 myself with MySQL support. I did a ./configure --with-mysqli=/usr/local/mysql/bin/mysql_config (see end of post for complete configure) Note: I also have...
0
by: Joonas Paalasmaa | last post by:
Hi, When compiling Sketch's streamfilter C extension the errors below are raised during linking. What could cause the errors? (Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98) Here are...
0
by: tyousaf | last post by:
Hi i am new to mysql and mysql++, i have installed mysql server, it is running fine. i also installed "mysql++-1.7.9gcc3.2-2.i386.rpm" (i have gcc 3.3) , first of all as the readme file says to do...
4
by: Aaron Queenan | last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the following error message: Linking... LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport LINK : error...
8
by: WebSnozz | last post by:
I have an application written in C that does a lot of low level stuff. It does a lot of things like casting from void*'s. I want to create a new GUI for it in either C# or MC++, but reuse the...
6
by: Cybex | last post by:
I am taking a C++ class and would like to use a Linux based IDE vs C+ + .Net but I am a little lost in how to go about this. I think that the IDE and compilation tools are separate under Linux. I...
2
by: renagade629 | last post by:
Can anybody help me understand what i'm doing wrong or what I'm missing? Is there anyother good and commendable C++ program I can use (free) from the internet like Dev C++? I'm having trouble doing...
2
by: Manikandan | last post by:
Hi, I have a program written in .Net Framework 1.1 using Visual studio enterprise edition 2003. I tried compiling the same program in visual c# express edition 2005. I'm getting following...
4
by: betalpha | last post by:
I'm having trouble compiling my program in Unix. I initially developed it on Windows in Eclipse. I have two files: Tokenizer.java and TokenizerMain.java. They are both in a directory called...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.