Welcome, Guest. Please login or register.

Author Topic: [C++] C++ 101  (Read 1586 times)

Offline Alex(aMacUser)

  • Global Moderator
  • General
  • *****
  • Posts: 1194
  • aMacUser is a name I picked up in High School
    • View Profile
    • eG
[C++] C++ 101
« on: August 29, 2012, 05:13:19 pm »
I am starting a very basic class on C++. I am willing to teach whatever I learn to anyone that is interested. My instructor informed me that we will be assigned a program almost every week.

You don't have to post here to display interest. Just message or talk to me on Teamspeak.

Class 2:
[spoiler]Learned that C++ is titled C++ because in C the syntax for adding one is x = x + 1 and in C++ the syntax is x = x++. C++ is simply one revision newer than that of "C". I hope I explained that correctly. Basically C++ is one revision newer than C.
Homework: Make a flow chart "program" that mimics a task you do in your daily life. Must contain a check loop and have more than 5 steps.[/spoiler]

Class 3:
[spoiler]Well I have been slacking a bit on updating this. Sorry to all the avid followers of this post. If you would like to learn more I can teach you while I am on teamspeak. I have a couple of new assignments as well as a guess the number game that I am working on. I have some notes that I am going to type up and add to this post as soon as I get a chance.
-Minor Update:
Here are some examples of comparisons in C++
[spoiler]
1. A < B //A is less than B
2. A > B //A is greater than B
3. A == B //compares if a is Equal in value to B
4. A = B //Note this is actually setting A as B and not comparing the two
5. A >= B //A is Greater than or equal to B
6. A != B //A is not equal to B
7. A <=B //A is less than or equal to B

!Remember! Comparisons in C++ return results as true or false!
#1. In this statement we are taking A and seeing if it has a lesser value than variable B. This is often times used in if statements and while loops. If you have questions feel free to ask in the comments.
#2. In this statement we are taking A and seeing it it has a greater value than B. This is the compliment to the first comparison.
#3. This is a tricky one for some beginners to coding. This statement is checking if the values stored in Variable A are equal to the Values stored in variable B. This is not setting B to A but rather checking if B is equal to A.
#4. This is setting B to the variable A. If B was equal to 4 and A was equal to 2, A will now equal 4. It overwrites the value in A with the value stored in B.
#5. This statement is checking if the Value stored in A is greater than or equal to the value stored in B.
#6. This statement is checking if the value in A is not equal to the value stored in B. So if A is 6 and B is 5 the result would return true. True because A is not equal to B in this case.
#7. This is the counter part to the expression in number 5 and should be self explanatory by now.

/*You can only compare certain types of variables in C++. Technically C++ will compare what you tell it to but it may cause runtime errors. Runtime errors are errors that are only found when the program has been compiled and is running. for example lets say you try to take a user input and divide it by another user input. If you do not have a method of checking the user input and the user inputs a 0 and tries to divide by 0 they will crash the program. Or throw an error.

Try it for yourself*/

Code: [Select]
/*
//Replace with your name
#################
#                                     #
# Created by aMacUser     #
#                                     #
#################
*/

//Defines what is included
#include<iostream>
    using namespace std;

//Starting of main.
int main(void)
{
       //defines a variable type integer that holds the value that the user will input
        int userInput = 0;
       //cin takes input from the keyboard and then is storing it into the pre defined variable
cin >> userInput;
        //cout is prining the output of the function, in this case the dividing function
        cout << userInput / userInput << endl;
        //system calls only work in windows. If you use a mac to code talk to me, I do.
system("pause");
return 0;


}
SORRY about the spacing. I wrote the code here instead of writing it in an IDE.
This program will crash. It should crash right after you enter an integer value of zero. It will try and divide by zero which is not possible.
[/spoiler][/spoiler]
« Last Edit: September 26, 2012, 04:47:50 pm by Alex(aMacUser) »

I have a lot of Macs probably 10 <> I do not use them to Game
I use a PC which I have Built myself (check the PC specs topic)

Offline fullsizeluxury

  • Global Moderator
  • General
  • *****
  • Posts: 752
    • View Profile
Re: [C++] C++ 101
« Reply #1 on: August 29, 2012, 08:16:10 pm »
I've taken two semesters of C++ and am in a Data Structures class now making my third semester, let me know if you need any help (recursion is a bitch)

Offline David

  • Co-Founder
  • Global Moderator
  • General
  • *****
  • Posts: 2906
  • Welcome To Our Forum!
    • View Profile
    • Echo Gaming
[C++] C++ 101
« Reply #2 on: August 29, 2012, 11:03:52 pm »
I am starting a very basic class on C++. I am willing to teach whatever I learn to anyone that is interested. My instructor informed me that we will be assigned a program almost every week.

You don't have to post here to display interest. Just message or talk to me on Teamspeak.

Class 2:
Learned that C++ is titled C++ because in C the syntax for adding one is x = x + 1 and in C++ the syntax is x = x++. C++ is simply one revision newer than that of "C". I hope I explained that correctly. Basically C++ is one revision newer than C.
Homework: Make a flow chart "program" that mimics a task you do in your daily life. Must contain a check loop and have more than 5 steps.
Sounds interesting, I'd be interested

Offline Alex(aMacUser)

  • Global Moderator
  • General
  • *****
  • Posts: 1194
  • aMacUser is a name I picked up in High School
    • View Profile
    • eG
Re: [C++] C++ 101
« Reply #3 on: August 30, 2012, 02:52:45 pm »
I've taken two semesters of C++ and am in a Data Structures class now making my third semester, let me know if you need any help (recursion is a bitch)
Ahh yes recursion, I remember working with that in HS, In my AP Java class we did a lot on the ideas and concepts of programing. We talked a lot about recursion and had some programs that we were required to make using recursive methods.

I have a lot of Macs probably 10 <> I do not use them to Game
I use a PC which I have Built myself (check the PC specs topic)

Offline fullsizeluxury

  • Global Moderator
  • General
  • *****
  • Posts: 752
    • View Profile
Re: [C++] C++ 101
« Reply #4 on: August 30, 2012, 03:45:55 pm »
What'd you end up using for your algorithm? A few teachers I know of have people do the "peanut butter and jelly" algorithm to show how much instruction computers need for shit in programming

Offline Alex(aMacUser)

  • Global Moderator
  • General
  • *****
  • Posts: 1194
  • aMacUser is a name I picked up in High School
    • View Profile
    • eG
Re: [C++] C++ 101
« Reply #5 on: August 31, 2012, 01:16:22 pm »
What'd you end up using for your algorithm? A few teachers I know of have people do the "peanut butter and jelly" algorithm to show how much instruction computers need for shit in programming
Not sure that I have heard it called that before but, I assume you are talking about the method that describes each step of a process in high detail. Or are you still on the recursion topic?

I have a lot of Macs probably 10 <> I do not use them to Game
I use a PC which I have Built myself (check the PC specs topic)

Offline Alex(aMacUser)

  • Global Moderator
  • General
  • *****
  • Posts: 1194
  • aMacUser is a name I picked up in High School
    • View Profile
    • eG
Re: [C++] C++ 101
« Reply #6 on: October 01, 2012, 02:28:07 pm »
Thread Has Been Updated. I Have no way of making this appear unread unless I make a new post. Correct me if I am wrong.

I have a lot of Macs probably 10 <> I do not use them to Game
I use a PC which I have Built myself (check the PC specs topic)

Offline Kablamo

  • Colonel
  • ****
  • Posts: 393
    • View Profile
Re: [C++] C++ 101
« Reply #7 on: October 22, 2012, 05:38:00 pm »
I'll help mac!