Thread: Hows (my) code progressing, good?

  1. #1
    Registered User
    Join Date
    Dec 2015
    Posts
    142

    Hows (my) code progressing, good?

    I made all of the code below and learned everything in that code only in today's time, and didn't know any of it yesterday, am I doing better than most?

    The code below works:

    Code:
    // My c++ Legend
    /* Contains
    all */
    
    
    #include <iostream>
    
    
    using namespace std;
    
    
    int main()
    {
        cout << "Enter a number: ";
        int x;
        cin >> x;
        cout << "You entered " << x << endl;
        if (x > 10)
        {
            cout << x << " is greater than 10" << endl;
            cout << x << " is a big number" << endl;
            if (x > 20)
            {
                cout << x << " is greater than 20" << endl;
            }
            else
            {
                cout << x << " is less than 20" << endl;
            }
        }
        else if (x < 10)
        {
            cout << x << " is less than 10" << endl;
        }
        else
        {
            cout << x << " is exactly 10" << endl;
        }
        return 0;
    }

  2. #2
    Registered User
    Join Date
    Dec 2015
    Posts
    142
    Also, if I create a new project "to be" my holy grail AI lol, should it be a Console Application?

  3. #3
    Registered User
    Join Date
    Dec 2015
    Posts
    142
    Guys?



    Thirdly, on top of my two above questions, now that I learned that code, I managed to make it in English and prove the world wrong, what the hell seriously you get a what the hell from me, that's not funny, it could have been written easy this means. See it below: (And this is only the beginning of my translation, plus I'd say I could go further)

    Code:
    /Comment on one line/
    //Comment extends through many lines until closure//
    
    
    #include <iostream>
    
    
    using namespace std;
    
    
    Start
    start integer for main()
    
    {
        give screen text "Enter a number: " end text;
        turn on x as number;
        get user inputed number x;
        give screen text "You entered " x end text;
        if (x exceeds 10)
        {
            give screen text x " is greater than 10" end text;
            give screen text x " is a big number" end text;
            give screen text "hi";
            give screen text " there" end text;
            if (x exceeds 20)
            {
                give screen text x " is greater than 20" end text;
            }
            else
            {
                give screen text x " is less than 20" end text;
            }
        }
        else if (x is lower than 10)
        {
            give screen text x " is less than 10" end text;
        }
        else
        {
            give screen text x " is exactly 10" end text;
        }
        turn on y as a number;
        give screen text "Enter a number: " end text;
        get user inputed number y;
        x = 5;
        x = x - 2;
        y = x;
        y = y + 4;
        give screen text "You entered " y end text;
        finish returns integer;
    }
    Last edited by ADVANCESSSS; 01-01-2016 at 09:25 PM.

  4. #4
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Hodor is confused

  5. #5
    Registered User
    Join Date
    Dec 2015
    Posts
    142
    All 3 of my question posts above are obvious, also I was recently talking to some of the members~

  6. #6
    Registered User
    Join Date
    Dec 2015
    Posts
    142
    If they're ignoring me then maybe I should go some place new that hasn't learned "oh, he's bad, oh ya" thought, it's the thought you gain and are just being ignorant to me and from being productive.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    You've basically turned C++ into COBOL
    https://en.wikipedia.org/wiki/COBOL

    Programming isn't made easier by making the language more verbose.
    This was learnt in the 1960's.
    Now you're learning it again.

    > if (x exceeds 10)
    ...
    > else if (x is lower than 10)
    So what would "x is greater than" mean?
    Is it the same as "exceeds", or not?


    > give screen text "Enter a number: " end text;
    What if my output is a file, or another program.
    cout is a stream to the outside world - it does not imply that it has to be a screen of some sort.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Dec 2015
    Posts
    142
    Oh ya, cin as in SEE IN could just be called "get from ". And a call could be "call/go to". You don't fool me, I'm writing it as I go and it IS simpler, and those two others can be get user input and print or output.

    COBOL doesnt have the full c++ arsenal.
    Last edited by ADVANCESSSS; 01-02-2016 at 02:54 PM.

  9. #9
    Registered User
    Join Date
    Feb 2015
    Posts
    74
    It is interesting!

  10. #10
    Registered User
    Join Date
    Dec 2015
    Posts
    142
    All "int"s should be start/create integer for my_name. Put a BIG START above main when it starrrrrrttsssss. Me doing very good see see!!

  11. #11
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by ADVANCESSSS View Post
    All "int"s should be start/create integer for my_name. Put a BIG START above main when it starrrrrrttsssss. Me doing very good see see!!
    If I may give a correction. Where a program starts is technically called the entry point.

    The entry point for C++ is actually rather complex since it can be before main() is called. Global objects like std::cout are initialized first, if you #include <iostream>. This is usually minor, but when you create your own object in global scope, it will be important to know when it is created.

    Additionally:
    Code:
    start integer for main()
    I would not write this. The first line inside of main(), located after the opening curly brace, is actually where main() starts.

    The int part in int main() is actually declarative. It only means that main will return an integer on completion: by convention, this value is 0 on success, and something else on failure.

    Your AI will most likely not be just a console program. Console programs are for hosted environments like your computer. For your AI, you or someone will have to embed the program(s) onto the chips of the hardware for the robot, after the software is written and tested.

    Basically, you need to target the robot's architecture.

    If your AI doesn't have a body to interact with, then it's hard to say what kind of project it is.

    But walk before you run. For now, it is okay to learn C++ with console applications on your computer.

  12. #12
    Registered User
    Join Date
    Dec 2015
    Posts
    142
    Yes that's why those are above main, they are done in sequence, but then you start at main and gobil gobil around following it all lol~

    But declaring int creates a storage binary integer dude, assigned to x or main.

    Yes I actually have to add that 0 at the end is the success only for ThE ending.

    Ok ok ok, so, what I'm doing first is coding my AI right, in only 1 Console Application right, then because it generates guesses this means it can be placed from Console Application to " " without corruption I hope and go into any robot and send the outputs to its servos right? Oh o, to test my AI I must put it innnn a robot....my c++ code doesn't need to be all formatted different does it!!?

  13. #13
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by ADVANCESSSS View Post
    But declaring int creates a storage binary integer dude, assigned to x or main.
    No, this is important. Function definitions give type names like int a different meaning. Just because you see an "int" before the function name, that doesn't mean that an int has been created. It simply tells you that an integer will be returned from the function.

    If you use the function in a variable definition, then you've got the int.

    Here, this might teach you the difference.
    Code:
    #include <iostream>
    #include <typeinfo>
    using namespace std;
    
    int dbl (int value ) {
      return value *= 2;
    }
    int main() {
       // prove dbl() function works:
       int result = dbl(4463);
       cout << "dbl() result = " << result << endl;
    
       // prove dbl is not an int:
       cout << "type of dbl() is " << typeid(dbl).name() << endl;
       return 0;
    }
    dbl clearly works, but it isn't an integer. You get a mangled function name instead.

    Ok ok ok, so, what I'm doing first is coding my AI right, in only 1 Console Application right, then because it generates guesses this means it can be placed from Console Application to " " without corruption I hope and go into any robot and send the outputs to its servos right? Oh o, to test my AI I must put it innnn a robot....my c++ code doesn't need to be all formatted different does it!!?
    Well, embedded programming is different from programming C++ for the computer because of the hardware. Smaller machines tend to have less memory, so they probably won't load all of the standard libraries.

    Again, instead of worrying about that you need to learn how to program in general. Every bit of hardware is different and it matters very much what you decide to use.

  14. #14
    Registered User
    Join Date
    Dec 2015
    Posts
    142
    Wha........the whole code you wrote worked the way I said - all of the ints made placeholders that went along through the code, all else worked as I know how it works, and dbl was just the name the whole time, then you outputed the name simply plus put typeid (dbl) .name() which doesn't kill anything I was proving either.

    So if I made the AI code, will I have to change it to go into hardware? Tell me what what what... Also I need to know if you can tell me how it's put in the robot and how do I get the camera's cout, I'm gonna face this and I gotta know....

  15. #15
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by ADVANCESSSS View Post
    Wha........the whole code you wrote worked the way I said -
    But you originally said "But declaring int creates a storage binary integer dude, assigned to x or main". Assigning something to main would mean that "main" would appear on the left side of an assignment statement. But that's not how you use main, or any other function.

    all of the ints made placeholders that went along through the code, all else worked as I know how it works, and dbl was just the name the whole time, then you outputed the name simply plus put typeid (dbl) .name() which doesn't kill anything I was proving either.
    All I set out to prove was that writing "int main()" where the function is define does not declare an int for storage. Everything up til now gave me the impression that you believed the opposite. That you actually understood the whole time is brand new information.
    So if I made the AI code, will I have to change it to go into hardware? Tell me what what what... Also I need to know if you can tell me how it's put in the robot and how do I get the camera's cout, I'm gonna face this and I gotta know....
    I don't have enough information to help you right now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. hows tihs sound system
    By MisterSako in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 07-19-2004, 11:36 AM
  2. Hows my new site I hand coded?
    By v3ct0r_sect0r in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 03-24-2004, 02:54 PM
  3. ODI? Hows 7 for 12 grab you?
    By Fountain in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 03-14-2004, 02:44 PM
  4. hows life fine i guess.Well i have a problem again
    By datainjector in forum C Programming
    Replies: 3
    Last Post: 07-02-2002, 11:48 PM
  5. hey, hows everyone's coding?
    By Ruflano in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 04-12-2002, 12:58 PM