GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-May-2005, 14:46
raptorhawk raptorhawk is offline
New Member
 
Join Date: Mar 2005
Posts: 25
raptorhawk is on a distinguished road

Problem with building


Ive created a program and when I go to build it Visual Studio tells me:

Code:
------ Build started: Project: Physics Converter, Configuration: Debug Win32 ------ Physics Converter - up-to-date. ---------------------- Done ---------------------- Build: 1 succeeded, 0 failed, 0 skipped

But when I go to find the .exe it is no where to be found. In addition the code appears to build far faster than it should. Can someone tell me whats going on.

CPP / C++ / C Code:
#include <iostream>

using namespace std;

float X;
float A;
float T;
float Vf;
float Vo;
float answer;
float temp answer;
int choice;

int main()
{
  cout << "Please select an equation that you want to use: \n";  // Gives you the option.
  cout << "(1) X = 1/2 A T^2\n"; // 1 or
  cout << "(2) Vf = Vo + AT\n"; // 2 or
  cout << "(3) Vf^2 = Vo^2 + 2 A X\n"; // 3
  
  cin >> choice;

  cout << "\nYour choice was " << choice << endl;  // Read back the choice

     if (choice == 1) // equation 1
     {
	     cout << "\nPlease enter the variables that you know.  
		 Please put a ? for the variable that you do not know.";
		 cout << "X: ";
	     cin >> X;
		 cout << "A: ";
		 cin >> A;
		 cout << "T: ";
		 cin >> T;
				
				if (X == ?)
				{
					answer = .5 * A * T * T;
				}

				else if (A == ?)
				{
					answer = (.5 * T * T)/X;
				}

				else if (T == ?)
				{
					temp answer = X / (.5 * A);
					answer = sqrt(temp answer);
				}

     cin.get();
     cout << "\nHere's the answer: ";
     cout << answer << endl;
     }
	 
	 else if (choice == 2)  // equation 2
     {
	     cout << "\nPlease enter the variables that you know.  
		 Please put a ? for the variable that you do not know.";
		 cout << "Vf: ";
		 cin >> Vf;
		 cout << "Vo: ";
		 cin >> Vo;
		 cout << "A: ";
		 cin >> A;
		 cout << "T: ";
		 cin >> T;
				
				if (Vf == ?)
				{
					answer = Vo + (A * T);
				}

				else if (Vo == ?)
				{
					answer = Vf - (A * T);
				}

				else if (A == ?)
				{
					answer = (Vf - Vo) / T;
				}

				else if (T == ?)
				{
					answer = (Vf - Vo) / A;
				}

     cin.get();
     cout << "\nHere's the answer: ";
     cout << answer << endl;
     }

	 else if (choice == 3) // equation 3
     {
	     cout << "\nPlease enter the variables that you know.  
		 Please put a ? for the variable that you do not know.";
		 cout << "Vf: ";
		 cin >> Vf;
		 cout << "Vo: ";
		 cin >> Vo;
		 cout << "A: ";
		 cin >> A;
		 cout << "X: ";
		 cin >> X;
				
				if (Vf == ?)
				{
					temp answer = (Vo * Vo) + (2 * A * X);
					answer = sqrt(temp answer);
				}

				else if (Vo == ?)
				{
					temp answer = (Vf * Vf) - (2 * A * X);
				}

				else if (A == ?)
				{
					answer = ((Vf * Vf) - (Vo * Vo)) / (2 * X);
				}

				else if (X == ?)
				{
					answer = ((Vf * Vf) - (Vo * Vo)) / (2 * A);
				}

     cin.get();
     cout << "\nHere's the answer: ";
     cout << answer << endl;
     }
     

     else  // Wrong number
     {
	 cout << "\nSorry, you entered an invalid number." << endl;
     cin.get();
	 }
	 
	 cout << "\nThank you for using Robert's Physics Converter.";

	 cin.get();
	 return 0;
}
__________________
*****Disclaimer*****

I am in no way a professional programmer nor do I play one on T.V.
  #2  
Old 16-May-2005, 15:13
Sokar Sokar is offline
Member
 
Join Date: May 2005
Posts: 243
Sokar has a spectacular aura aboutSokar has a spectacular aura about
The code you posted does not even begin to compile.

You can not have a space in a variable.
CPP / C++ / C Code:
float temp answer;

Maybe,
CPP / C++ / C Code:
float temp_answer;
You can not put this on two lines like you have.
CPP / C++ / C Code:
     if (choice == 1) // equation 1
     {
       cout << "\nPlease enter the variables that you know.  
Please put a ? for the variable that you do not know.";
Maybe,
CPP / C++ / C Code:
     if (choice == 1) // equation 1
     {
       cout << "\nPlease enter the variables that you know.  " 
<<  " Please put a ? for the variable that you do not know.";
You will need to add some single quotes
CPP / C++ / C Code:
        if (X == ?)
        {
around the '?' like so
CPP / C++ / C Code:
        if (X == '?')
        {
There are still many errors that I did not point out that you will need to fix before it will compile.
  #3  
Old 17-May-2005, 08:47
raptorhawk raptorhawk is offline
New Member
 
Join Date: Mar 2005
Posts: 25
raptorhawk is on a distinguished road
Ok, I fixed all of those problems but I still can't see what is causing it to not compile. Why is it not trying and giving me a page full of errors.

I also changed
CPP / C++ / C Code:
cout << "X: ";
cin >> X;
cout << "A: ";
cin >> A;
cout << "T: ";
cin >> T;

to
CPP / C++ / C Code:
cout << "X: " << X << "\n";
cout << "A: " << A << "\n";
cout << "T: " << T << "\n";

When I declare the variables should I use float or int?

Also do I need a single quote around the ? when I use it in the printed message. Also do I need a single quote around µ.
__________________
*****Disclaimer*****

I am in no way a professional programmer nor do I play one on T.V.
  #4  
Old 17-May-2005, 08:55
Kacyndra's Avatar
Kacyndra Kacyndra is offline
Member
 
Join Date: May 2005
Location: Maryland
Posts: 226
Kacyndra will become famous soon enough
hi
"temp answer" i'm not sure but i dont think thats allowed. I think you might want to connect the name with a _ or somehting. To make it one word.
Why Don't you paste the compiler erros. It would just be that easier to see whats going on.
__________________
Xrum!
  #5  
Old 17-May-2005, 09:33
Sokar Sokar is offline
Member
 
Join Date: May 2005
Posts: 243
Sokar has a spectacular aura aboutSokar has a spectacular aura about
Quote:
Originally Posted by raptorhawk
Ok, I fixed all of those problems but I still can't see what is causing it to not compile. Why is it not trying and giving me a page full of errors.
I am not sure. But you did not offer the version of "Visual Studio" it might be something to do with a particular version of "Visual Studio". Have you change any options that might disable the warnings. You might try making a new project and just copy and paste your code to a new project and see if that helps.

Quote:
Originally Posted by raptorhawk
When I declare the variables should I use float or int?
If you want to have variables that have a decimal then use float. If you do not need the decimal then use int.
CPP / C++ / C Code:
int var1 = 10;// no decimal
float var2 = 22.56f;//decimal

Quote:
Originally Posted by raptorhawk
Also do I need a single quote around the ? when I use it in the printed message.
No you would need to use it as an escape sequence.
http://msdn.microsoft.com/library/en...reftable_3.asp
http://www.cppreference.com/escape_sequences.html
CPP / C++ / C Code:
cout << "Hello \?" << endl;
  #6  
Old 17-May-2005, 14:18
raptorhawk raptorhawk is offline
New Member
 
Join Date: Mar 2005
Posts: 25
raptorhawk is on a distinguished road
Ok, I found out why I wasnt getting any errors. Turns out I forgot to link my source file to the project . Now that I have taken care of it I was able to fix several problems. I have just three left and I dont know how to deal with them.

These are my errors:
Code:
(5) : warning C4091: '' : ignored on left of 'int' when no variable is declared (5) : error C2143: syntax error : missing ';' before 'constant' (5) : fatal error C1004: unexpected end of file found

Here is the relevent piece of my code:
CPP / C++ / C Code:
#include <iostream>

using namespace std;

int '?';

and:
CPP / C++ / C Code:
if (X == '?')
{
answer = .5 * A * T * T;
}

Am I doing this properly?

Also can you tell me if I am doing the square roots properly
CPP / C++ / C Code:
else if (T == '?')
{
temp_answer = X / (.5 * A);
answer = sqrt(temp_answer);
}

Thanks again for the help.
__________________
*****Disclaimer*****

I am in no way a professional programmer nor do I play one on T.V.
  #7  
Old 17-May-2005, 14:30
Kacyndra's Avatar
Kacyndra Kacyndra is offline
Member
 
Join Date: May 2005
Location: Maryland
Posts: 226
Kacyndra will become famous soon enough
ok
here you go
Code:
int '?';
you can't do that
a ? is not an integer, it's a character.
You need to first delcare a character(in this case i named it QMark), and then assign
the charecter to it (?)
you declare it the following way:
Code:
char QMark = '?';
or
Code:
char QMark; QMark = '?';
whatever is easier for you to understand

that should probably take care of it. The rest of the errors are most likely generated becaseu of that one statment. Fix it, and let me know how it goes
__________________
Xrum!
  #8  
Old 17-May-2005, 19:33
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Or better yet:
CPP / C++ / C Code:
#define QMARK '?'
which doesn't use any memory and can't be accidentally changed thru programming error.

Also, use QMARK everywhere in place of '?'. That way if you need to change the character you only have to do it in one place.
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #9  
Old 17-May-2005, 22:19
Dave Sinkula Dave Sinkula is offline
Member
 
Join Date: Apr 2005
Posts: 199
Dave Sinkula will become famous soon enough
Quote:
Originally Posted by WaltP
Or better yet:
CPP / C++ / C Code:
#define QMARK '?'
which doesn't use any memory and can't be accidentally changed thru programming error.

Also, use QMARK everywhere in place of '?'. That way if you need to change the character you only have to do it in one place.
But wouldn't
CPP / C++ / C Code:
#define QMARK '!'
seem a little odd?
  #10  
Old 18-May-2005, 01:30
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
That's why I'd personally use
CPP / C++ / C Code:
#define CHR_UNKNOWN '?'
in this program...
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphic problem in Unreal Tournament 2004 zerox Computer Software Forum - Games 10 09-Oct-2005 13:31
Building problem hvtin MS Visual C++ / MFC Forum 2 08-Feb-2005 03:07
Problem Building New Computer Dark Serge Computer Hardware Forum 4 31-Aug-2004 16:19
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 08:53
problem with php5 cgi installation fab13 Apache Web Server Forum 3 19-Nov-2003 10:11

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:40.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.