#include <iostream>
#include <cstdlib>
#include <string>
int main(void){
int a = "";
int b = "";
int c = "";
cout<<"What is the A value"<<endl;
cin>>a;
cout<<"What is your B value?"<<endl;
cin>>b;
cout<<"What is your C value?"<<endl;
if(a ++ b > c);
{
cout<<"You have an obtuse triangle"<<endl;
}
if(a ++ b < c);
{
cout<<"You have an acute triangle"<<endl;
}
if(a ++ b == c);
{
cout<<"You have a right triangle"<<endl;
}
system("PAUSE");
return 0;
}
... and are some of my includes not needed?
Thanx for even reading
EDIT: I forgot to say I am using MS Visual C++ 6.0
and i get these errors:
--------------------Configuration: What Kind Of Triangle Do I Have - Win32 Debug--------------------
Compiling...
What Kind Of Triangle Do I Have.cpp
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(7) : error C2440: 'initializing' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(8) : error C2440: 'initializing' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(9) : error C2440: 'initializing' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(10) : error C2065: 'cout' : undeclared identifier
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(10) : error C2297: '<<' : illegal, right operand has type 'char [20]'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(10) : error C2065: 'endl' : undeclared identifier
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(11) : error C2065: 'cin' : undeclared identifier
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(11) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(12) : error C2297: '<<' : illegal, right operand has type 'char [22]'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(13) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(14) : error C2297: '<<' : illegal, right operand has type 'char [22]'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(15) : error C2146: syntax error : missing ')' before identifier 'b'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(15) : error C2059: syntax error : ')'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(15) : warning C4552: '>' : operator has no effect; expected operator with side-effect
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(17) : error C2297: '<<' : illegal, right operand has type 'char [28]'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(19) : error C2146: syntax error : missing ')' before identifier 'b'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(19) : error C2059: syntax error : ')'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(19) : warning C4552: '<' : operator has no effect; expected operator with side-effect
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(21) : error C2297: '<<' : illegal, right operand has type 'char [27]'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(23) : error C2146: syntax error : missing ')' before identifier 'b'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(23) : error C2059: syntax error : ')'
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(23) : warning C4553: '==' : operator has no effect; did you intend '='?
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(25) : error C2297: '<<' : illegal, right operand has type 'char [26]'
Error executing cl.exe.
What Kind Of Triangle Do I Have.obj - 18 error(s), 5 warning(s)
[edited by - TheNerdTk421 on February 19, 2004 9:43:04 PM]
Hello Gamedev Forums!
Iwould like to say hello.... and i would like some one to give me some pointers if possible about my code
Why are you using "++"? How about just "+"? "++" is the incrementing operator, and will only increase by one, not the right operand. Also, I don't believe you need the "string" header.
EDIT: Add "using namespace std," or replace cout, cin, and endl with std::cout, std::cin, etc.
[edited by - cOWsaReNotEVil on February 19, 2004 9:45:01 PM]
EDIT: Add "using namespace std," or replace cout, cin, and endl with std::cout, std::cin, etc.
[edited by - cOWsaReNotEVil on February 19, 2004 9:45:01 PM]
initialize an int with an integral value i.e. 0, but not "". Which might be done with string types in visual basic often.
What would i use instead of endl; std::endl; ? \and what does this mean? :
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(23) : warning C4390: ';' : empty controlled statement found; is this the intent?
[edited by - TheNerdTk421 on February 19, 2004 9:53:00 PM]
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(23) : warning C4390: ';' : empty controlled statement found; is this the intent?
[edited by - TheNerdTk421 on February 19, 2004 9:53:00 PM]
what does this mean?
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(24) : warning C4390: '';'' : empty controlled statement found; is this the intent?
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(24) : warning C4390: '';'' : empty controlled statement found; is this the intent?
quote:Original post by TheNerdTk421
what does this mean?
C:\Documents and Settings\patrick\Desktop\GeoApps\What Kind Of Triangle Do I Have.cpp(24) : warning C4390: ';' : empty controlled statement found; is this the intent?
Actually, when doing if statements, don't end it with a semicolon. Any expression that is tested with if or while statements etc, don't use a semicolon.
[edited by - nervo on February 19, 2004 10:01:28 PM]
#include <iostream>usinge namespace std; //DONT FORGET THIS!!! also you didnt need those other librariesint main(){int a =0;int b =0;int c =0;cout<<"What is the A value"<<endl;cin>>a;cout<<"What is your B value?"<<endl;cin>>b;cout<<"What is your C value?"<<endl;cin>>c; //you forget this??if(a + b > c)//no semicolon herecout<<"You have an obtuse triangle"<<endl; //if its just one line of code after the IF, you dont need to put brackets, but you could if it helps for read-abilityif(a + b < c)cout<<"You have an acute triangle"<<endl;if(a + b == c)cout<<"You have a right triangle"<<endl;//no need for a system PAUSE here at allreturn 0; }
just thought id optimize your code a little, this it what it "should" look like. im a newbie too, but i could at least figure this out . good luck man!!
[edited by - graveyard filla on February 19, 2004 10:01:13 PM]
#include <iostream>#include <cstdlib>int main(void){int a;int b;int c;std::cout<<"What is the A value"<<std::endl;std::cin>>a;std::cout<<"What is your B value?"<<std::endl;std::cin>>b;std::cout<<"What is your C value?"<<std::endl;std::cin>>c;if(a + b > c) std::cout<<"You have an obtuse triangle"<<std::endl;if(a + b < c) std::cout<<"You have an acute triangle"<<std::endl;if(a + b == c) std::cout<<"You have a right triangle"<<std::endl;}system("PAUSE");return 0; }
EDIT:hey thanx use to program quite a bit (C, C++ not to dif) but it been years... works!! THANX ALOT!! now to more stuff!! YAY
[edited by - TheNerdTk421 on February 19, 2004 10:04:49 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement