Thread: Need opinion...
View Single Post
Old Jan 24th, 2005, 8:45 AM   #43
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
Red face

#include <iostream>
using namespace std;

***************************0************************
string str1;
int a;
int b;
int c;
float d;
float e;

int main();***************1*****************
{
    int a = 2;
    int b = 5;
    float d = 0.5;
    cout << "stupid little operators test by Broax...\n";
    a + b = c;*****************2*********************
    c + d = e;*****************3*********************
    e >= 4 ? cout << "testA" << : << "testeB" << endl;**************4*****************
    cout << "The result is: " << e << endl;
    
    return 0;
}

refer to the areas marked by asterisks and shit...

0. these variables must be declared in the function that they are used. put them inside the "int" main" part...major programming error.

1. there is no semicolon between int main() and the first brace ( { )...minor syntax error.

2. don't think of this sign here---> =
as the "equals" sign. think of it as the assignment operator. every time you think about an expression like this think this: "take what is on the RIGHT side and put that value into the LEFT side. example:

int x = 3 //put the value 3 into the variable x.

as soon as you think of it as this "right to left" idea, things get much easier. so when you tell the compiler to add two variables and then put a value into them it has no fucking idea what you're talking about. if "x" is a jar then you tell the program to put whatever is on the right side into the jar "x". from then on, when you say "x" it will see what you put into it. remember, in C++ "=" is the assaignment operator, "==" is what actually means "equals". point is ONLY PUT ONE THING ON THE LEFT SIDE.

3. same thing...major programming error (don't worry, the best way to learn is through errors, if you always did everything right then you're either a god or a lucky fool. the compiler can be a great teacher. listen to it.

4. i beleive you want to put an "if" statement here...major programming error.

try this finished code...
#include <iostream>
using namespace std;

int main()                    ***************1*****************
{

string str1;
int a;
int b;
int c;
float d;
float e = 6.768;
float f;

    int a = 2;
    int b = 5;
    float d = 0.5;
    cout << "stupid little operators test by Broax...\n"<<endl;
    c=a+b;              *****************2*********************
    f=d+e;               *****************3*********************
    if (f >= 4)
         { cout << "the condition is held TRUE so i am printing this                                                                                        shit"<<endl;
              }            **************4*****************
    cout << "The result is: " << e << endl;
    
    return 0;
}
the code is kinda dumb, but so am i after nine beers. that's about all i'm prepared to deal with.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.

Last edited by bl00dninja; Jan 24th, 2005 at 8:50 AM.
bl00dninja is offline   Reply With Quote