473,320 Members | 1,951 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,320 software developers and data experts.

small error

Expand|Select|Wrap|Line Numbers
  1. //Lab 9 Problem 3 program that allows user find mass of a particle
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {//defining variables
  6. float m, v, count;
  7. char exit_variable;
  8. cout<<"This is a programme to determine the mass of a particle";
  9. v = 0.2;
  10. while (v<=0.9)
  11. {m=1/(sqrt(1-(v*v)));
  12. cout<<"   when v is"<<v;
  13. cout<<"\nThe mass of the particle is"<<m;
  14. v=v+.1;
  15. }
  16. cout<<"Press any key to exit";
  17. cin>>exit_variable;
  18. }
  19.  
  20.  
Oct 31 '08 #1
2 1026
boxfish
469 Expert 256MB
When you are asking a question, please post any compiler errors you are getting, what your program is supposed to do, and what it is doing instead. You need to learn how to debug your own programs. Please follow the Posting Guidelines.
Thanks.
Oct 31 '08 #2
archonmagnus
113 100+
I do see a few errors in your code. First, the "sqrt" function is defined in the "cmath" library. Otherwise you have no function declaration for the "sqrt" function and the compiler complains that it can't find the function to use. In otherwords, add the preprocessor directive:
Expand|Select|Wrap|Line Numbers
  1. #include <cmath>
  2.  
Second, check the line:
Expand|Select|Wrap|Line Numbers
  1. ...
  2. cout<<"   when v is"<;<v;
  3. ...
  4.  
You are missing the correct binary operator "<<" for "cout" (i.e. remove the extraneous semi-colon). The line should read:
Expand|Select|Wrap|Line Numbers
  1. ...
  2. cout<<"   when v is"<<v;
  3. ...
  4.  
Those minor edits should fix your code. I hope that helps.
Nov 1 '08 #3

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

Similar topics

10
by: Alex Vinokur | last post by:
What is wrong with small_buffer in program below? I/O getline doesn't read data from file into small (relative to file line size) buffer. ====== foo.cpp ====== #include <cassert> #include...
5
by: F. Barth | last post by:
Hello, I've posted this problem to one other newsgroups, and gotten some diagnostic help, but I still need a solution. The full text of the message box is: "The field is too small to accept the...
49
by: Lauren Wilson | last post by:
Hi folks, Just wondered if, for the sake of clarity, it is permissible to post small image files of an error box along with a text message about a problem with Access?
0
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
3
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
16
by: lawrence k | last post by:
I've a file upload script on my site. I just now used it to upload a small text document (10k). Everything worked fine. Then I tried to upload a 5.3 meg Quicktime video. Didn't work. I've...
2
by: BKMiller | last post by:
Hello everyone, I'm just getting started playing around with C++, so please don't laugh too loudly at my crude source code, okay? (o^^o) I'm combining together several introductory exercises...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
7
by: Morias | last post by:
I have been trying to install a Zebra LP2844 on a computer running Windows XP. When using the add printer wizard I get an error that simply tells me "The printer could not be installed," but when...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.