- Joined
- Aug 4, 2010
- Messages
- 572
- Reaction score
- 177
I'm just going to make this guide for the fun of it, cause i'm really bored and I also want others to learn the ways of coding so I hope you understand their not complicated were starting from step from 1 - 6 and I'll make more guides for beginners after.
-When I'm explaining which function is ... Please don't say its wrong its my way of saying what it means.
Programs needed, any C++ compiling program, GL.
C++ Made Easy.
-----------------
C++ For Programming
-----------------
That's the end of Step 1.
--All Codes were tested before written, thanks for reading if you did.
-When I'm explaining which function is ... Please don't say its wrong its my way of saying what it means.
Programs needed, any C++ compiling program, GL.
C++ Made Easy.
-----------------
C++ For Programming
-----------------
Code:
[B][U]Step 1 : Simple Hello World Program.[/U][/B]
#include <iostream> // Include IO Stream Library Files.
using namespace std; // Include Files From Standard Library.
int main() // Main file header, (ALWAYS NEEDED).
{ // BEGIN BRACE BRACKET BRACE = {
cout <<"Hello World!"; // Your Text That You Want Displayed.
<< endl; // To Close The Statement "Cout" or others.
cin.get(); // To Keep Your Written Program on the screen so that you can see what you've written.
} // END BRACE BRACKET = } Must Need when ending a statement, the same goes for { for beginning a statement.
That's the end of Step 1.
Code:
[B][U]Step 2 : Variables & User Input.[/U][/B]
#include <iostream> // Include IO Stream Library Files
using namespace std; // Include Standard library files (cout).
int main() // Main Function header file (Always Needed).
{ // BEGIN BRACE BRACKET
int age; // Variable. Mines is named "age". Always have your semi colen.
cout << "How Old Is WizCoder: "; //The Output question that was asked.
cin >> age; // User Input when guessing your age.
cin.ignore(); // Ignore all characteristics.
cout << "You Entered: " << age <<endl; // Output message of what the input user has entered.
cin.get(); // Keeps your programming on the screen when compiling
} // END BRACE BRACKET.
[B][U]END OF STEP 2.[/U][/B]
[B][U]
Code:
Step 3 : If and Else.[/U][/B]
#include <iostream> // IO Stream Library files.
using namespace std; // Includes Standard Library files.
int main() // Main Function Header File.
{ // BEGIN BRACE BRACKET.
int age; // My Variable Name "age".
cout <<"How old Is WizCoder: "; // Output Question Asked.
cin >> age; // User input of guessing your age.
cin.ignore(); // Ignore all characteristics.
if ( age == 14 ) { // If, age = 14, then your correct.
cout << "Correct";
} // End Brace BRACKET.
else if ( age == 13 ) { // else if, age = 13 your close, this can be added to by copying the exact code and pasting but change the number.
cout << "Nice try, But your close ";
}
else { // For All other numbers, that you haven't included will get the message below.
cout << "Your Totally wrong, try again.";
}
cin.get(); // Displays your coding on the screen instead of flashing. (Always include this at the bottom of your coding.)
} // END BRACE BRACKET.
[B][U]END OF STEP 3.[/U][/B]
Code:
Step 4 : Loops.
#include <iostream> // Include IO Stream Library Files.
using namespace std; // Include Standard Library Files.
int main() // Main Function Header File ( Always Needed.)
{ // BEGIN BRACE BRACKET.
int x; // Variable name = "x" but you can change.
for (int x = 0; x < 10; x ++ ) { // Loop settings, int x = 0; x Less Than 10; x ++ ), Displays The Message Numbers 10 times, but in C++ coding 1 = 0, and 2 = 1 Try to understand by playing around with this.
cout << x <<endl; // Displays your "x" variable according to above.
} // End BRACE BRACKET.
cin.get(); // Keeps your programming message displayed on the screen.
} // END BRACE BRACKET.
[B][U]END OF STEP 4.[/U][/B]
[B][U]
Code:
Step 5 : Things You Should Understand From Now.[/U][/B]
Here are the relational operators, as they are known, along with examples:
> greater than 5 > 4 is TRUE
< less than 4 < 5 is TRUE
>= greater than or equal 4 >= 4 is TRUE
<= less than or equal 3 <= 4 is TRUE
== equal to 5 == 5 is TRUE
!= not equal to 5 != 4 is TRUE
Comment Lines Adding Your Comments For Instructions Readers.
*/ (Comment You want To say) /*
*/ Means Opening Comment, /* Means your finish your comment.
OR
// = Opening your comment when you want to state something.
And Signs Important !
So Sometimes you can't use the word "And" or type & when you want to include another word. With C++ its mandatory to use the double signs "||" To use that hold Shift + the key on the left of <-- Sign.
[B][U]END OF STEP 5.[/U][/B]
Code:
[B][U]Step 6 : Functions.[/U][/B]
#include <iostream> // Include IO Stream Library Files.
using namespace std; // Include Standard Library files.
int mult ( int x, int y ); // Function Variable That you want to get multiplied " int x, int y" You can name "x" & "y" to whatever you want.
int main() // Main Function Header File (Always Needed.)
{ // BEGIN BRACE BRACKET.
int x; // Interger Variable "x" you can change name.
int y; // Interger Variable "y" you can change name.
cout <<"Enter what numbers you want to be multiplied: "; //Your Question That your giving.
cin >> x >> y; // User input directing according to question sent.
cout << "The Answer to your following question is : " << mult ( x,y ); // Output of the users "C In" input that he has written.
cin.ignore(); // Ignore all characteristics.
cin.get(); // Keeps your message( coding ) displayed on the screen.)
} // Close Brace BRACKET.
int mult ( int x, int y) // Interger that you wanted to be multiplied, look above at line 3 their the same.
{ // BEGIN BRACE BRACKET.
return x * y; // Showing The end value x * y. * = Times = X.
} // END BRACE BRACKET.
--All Codes were tested before written, thanks for reading if you did.
Last edited: