Pshyotic

Members
  • Content Count

    235
  • Last visited

Everything posted by Pshyotic

  1. I will work to answer this thread every day in this same thread with a new tutorial, so everything will happen in this topic and there will not be another topic open. Hello everyone, here we are in the new tutorial of the C ++ programming language. DON'T FORGET TO LEAVE LIKE If you have any questions about some of the previous tutorials or questions for this tutorial, please contact PM (Private Messages) or answer here on my topic so I can help you. PART 1. [hide] What you definitely need as far as the theory is concerned is the following: 1.What is programming? -Programming is how to write instructions to a computer what to do and how to do it and run in one of the programming languages. Programming is art and craft in creating computer programs. Creating a program contains elements of design, art, science, mathematics as well as engineering. The person who creates the program is called the developer. 2.What are the variables ? -Variable (or variable) is a unit given or information in a computer program that can change the value during program execution. The opposite term is a constant or invariable representing a unit given, that is, information that does not change during the execution of the program. (We will speak more about variables in example later where will I give you one explanation and simplify this definition.) 3.What is compiler ? -The language translator (including translator, translator, program translator, program translator, compiler, and colloquially often compiler) is a computer program that reads the program written in the original language and translates it into the equivalent program in the target (most commonly used) language . So, we should now go on basic thing about C++ . We have to know types of variable in C++ (which are also known as Data types and they are very important in every single programming lang.). https://i.stack.imgur.com/wM1Cu.png[/img] And probably you will wonder now, what will these numbers mean to me and what's all this on this picture. So here is one explanation about variables: How do I understand variables? Imagine that you have one box in which we put our things and of course they occupy a certain space on our waist, floor and the like. So the variables in it include a certain data and that variable occupies a certain part of the computer memory. I turn back to the picture, these numbers you see, they actually represent how much a particular type of data takes memory and we have to be very careful when we use that variable. For example, the type of int (integer) data has 16 bits and can crawl numbers such as 0,1,2,3,4,5,6,7,8,9,10,11 ... and so on enter the number: 50439412321342 program will collapse and it is called overflow, and it happens very often to new developers, so every type of data has a certain maximum number that it can go to. What if one integrer type variables joined 12.99? The program would not collapse however it would have been that if you would print that variable in our console, only number 12 would be printed without this residue, 99 ... Wondering why? Again, it is a matter of data type, the type of data integer (int) does not have the scope to save the number with a decimal comma, because there are types of data such as float, double etc. but we will talk about it a little later. For now, before catching any serious programming, it's enough to remember the type of data: int and float or double. Now let's go to the concrete example that all of us programmers have passed (or at least most of us when we are learning a new programming language). //first c++ program #include using namespace std; int main() { cout << "Hello, World!"; return 0; } So let's go and analyze this code. //first c++ program These are actually comments and they do not play any role in the compiler, which means the compiler does not see them and circumvent them and goes to our code. Programmers use them to include short explanations or observations on the code or program. In this case, it is a brief introductory description of the program. #include What does this actually do #include ? Lines beginning with a hash sign (#) are directives read and interpreted by what is known as the preprocessor. They are special lines interpreted before the compilation of the program itself begins. In this case, the directive #include , instructs the preprocessor to include a section of the standard C ++ code known as header iostream, which allows to perform standard input and output operations such as writing the output of this program ) to the screen. It actually include (the same meaning), the iostream header (or the input / output stream library that serves us to perform the cout actions and the steps we will touch a little later). So this line of code tells our pre-processor to include that library (look it up where we installed our program, compiler ... eg CodeBlocks, Visual Studio etc ...). How can you also understand this is the following example. I believe that you all played Counter Strike 1.6, and when you enter the server, note that those lines are full and you see that something is reading something and that the game is "loaded" without the download, that some programmer forgot to type #include , you probably would not have a weapon in your hands. So also here in this program, without #include you would have left without your "weapon" ie without your text and I would get you an error or BUG. Without this line of code our cout << "Hello, World!"; it would not work and get what every programmer hates most and what every nightmare programmer is, and that's BUG. What will cause BUG? Well just because there is no input / output stream library ... What are the libraries? Libraries are actually (in programming) certain codes written by people that we should not always have to write a code for printing / entering data and similar things. Just imagine how hard it would be to write it all over again just to print some text in the console. That's why some programmers have deprived us of this tedious job by writing that code and giving us this library that is automatically installed with each program you use to write the program. using namespace std; In C ++ there are a set of functions that are needed by many users and are regularly delivered with the program. A set of all such standard functions is called a common library called the standard library. The functions of the standard library are not located in one library but are located in various libraries but are all, agreed, marked with an additional name std. This is not necessary for us to write, but then we will add more writing, so without using namespace std; this code looked like this: #include int main() { std::cout << "Hello World!"; } Here, you do not seem to look very tired here, but imagine that your code has 200 lines of code and you have to write "std::" int main() { Now let's go back to the first part of the code. int main () { which could look like: int main () { Just to say there are no differences between these two, but there are some developers in the code as in the first case, and some like everything else is a taste and of course none of these is wrong and will not affect your code. This line initiates the declaration of a function. Essentially, a function is a group of code statements that are given a name: in this case, this gives the name "main" to the group of code statements that follow. Functions will be discussed in detail in a later chapter, but essentially, their definition is introduced with a succession of type (int), a name (main) and a pair of parentheses (()), optionally including parameters. The function named main is a special function in all C ++ programs; it is the function called when the program is run. The execution of all C ++ programs begins with the main function, regardless of where the function is actually located within the code. Next, we'll get the parameters but the "function" that looks like this without any code inside it: int main() { } This function MUST have each code, because that's what you see MAIN FUNCTION. We will also have some functions later on, so I'll explain you more later. { and } . The open brace ( { ) at line 5 indicates the beginning of the main function definition, and the closing brace ( } ) at line 7, indicates its end. Everything between these braces is the function's body that defines what happens when the main is called. All functions use braces to indicate the beginning and end of their definitions. cout<<"Hello, World!"; This line is a C ++ statement. A statement is an expression that can actually produce some effect. It is the meat of a program, specifying its actual behavior. Statements are executed in the same order that they appear within a function's body. The insertion operator (<<), which indicates that what follows is inserted cout. Finally, a sentence within quotes ("Hello world!") is the content inserted in the standard output. Notice that the statement ends with a semicolon (;). This character marks the end of the statement, just as the period ends in a sentence in English. All C ++ statements must end with a semicolon character. One of the most common syntax errors in C ++ is forgetting to end an statement with a semicolon. int main () { cout << "Hello World!"; } Also, this code we could write and so, however, as you see it and not very straightforward. Yet neatness is all. return 0; returns 0, a common way to say "if you have reached this point, no error has occurred" And that's actually it. Another thing as far as the comments are concerned. You have this kind of comment: //Bla Bla Bla and a comment ("//") means that as long as we type in the current line any compiler will ignore it. However if we write // Bla Bla Bla (and then skip to the next row and write anything else, the compiler will make a mistake (BUG)). The second type of comment is: / * * / In this type of commentary you can write everything you want wherever you want in / * * / and until you exit * /, the compiler will not flash. Example of correct comment: / * Bajsifa dfkogsd daslpfadfdfdfdf * / An example of incorrect comment / * Bajsifa * / dfkogsd daslpfadfdfdfdfd After this you get a mistake in the compilation. That would be all for this tutorial. If I forgot something I would ask the developers to add that. [/hide] [align=center]That would be all for this tutorial. I hope you enjoyed and of course learned something new.[/align]
  2. Thanks a lot of... Hope some of this will work <3
  3. Welcome, hope you'll get everything you want. Good luck!
  4. Heh... You are a Little bit late but , because I found explanation of it... But thank you, anyways for your time...
  5. Hello, So I am here to ask to get RANK for "Active member". I have posted about 2-3 threads, one in feedback & sugestion section to aprove tutorials for programming and this is I think my top thread... There is also thread about one of my old codes where I made game when I was on beggining of programming... So, even if you think that I have posted just 2-3 threads and this is not enough threads I think that is better post 2 or 3 quality treads instead of having 100 threads and there are no quality... As I said I suggest tutorials for programming and if this is going to be approved I would make one thread where will I teach and ggive other chance to learn programming in C++ programming language... And when I mention this all on the end I would like if I can get and Coder rank and there is my knowledge in C++ and Python... Thanks
  6. Thanks, nice from you too. But we must for approve of this idea.. And as you can see, no one respond..
  7. Hello Karan, You can contact me in p.m. so I can give you some directions and introduction in programming... Feel free to send me p.m
  8. Hello everyone, I don't know how much of you know for this application but here it is. You earn $ by doing some quest in games like CS:GO, League of Legends and etc. it's tested and it works, you get your money on paypal. You can earn 5$ in 2 days by playing LOL. Even if isn't allowed in your country just download VPN and that's it. Good luck Here it is: [hide]http://www.playvig.com[/hide]
  9. Hello everyone, so this was my first game I created in C++ ...It isn't something big but, like I just said that was my first game... So in link above you will have source code and you can run it, because it is online compiler... And in the case that this the code is fairly simple, there are used functions and srand (a function that generates random numbers)... So I posted it because I thought it will be helpful for someone (like newbies in programming) http://cpp.sh/5bc2p
  10. You probably did not give a good description... But both of us want same, so yeah... Good luck to us hahaha... and yeah wanted to say thanks to other that support my idea :)
  11. Thanks. Now we just should be patient and wait for administrators decision. And yeah nice from you :10:
  12. Hello everyone, It's a lot of section and there is also section for programming but I wanted to know can we start a new thread for tutorials in programming, that will be good for this forum and I mean why not ? I think a lot of programmers are in search for good forum where they can ask for solution or explanation for something... I would first post a new thread about C++ programming languange and basics about that and one of god stuff's is that, that everyone could "add" his comment and mybe his suggestion and explanation of something...
  13. Thanks a lot man <3 nice share
  14. Okay, I think I'll wait for example code, but what I get is this that inline function and recursion is good for dynamic programming... And hell so I think that the rest of my life will be reduced to dynamic programming, since it comes down to what is known as "divide and rule", yet there are many functions, classes and objects ...
  15. Hello everbody, I first want to say that I couldn't find the corresponding section of the forum to post and ask things about programming, so I hope here will be okay and I think that this forum should have section for this purpose. So, I really don't get mean of inline function in C++ , .. Here is one of the codes for this: 1: // Listing 5.9 - demonstrates inline functions 2: 3: #include 4: 5: inline int Double(int); 6: 7: int main() 8: { 9: int target; 10: 11: cout << "Enter a number to work with: "; 12: cin >> target; 13: cout << "\n"; 14: 15: target = Double(target); 16: cout << "Target: " << target << endl; 17: 18: target = Double(target); 19: cout << "Target: " << target << endl; 20: 21: 22: target = Double(target); 23: cout << "Target: " << target << endl; 24: return 0; 25: } 26: 27: int Double(int target) 28: { 29: return 2*target; 30: } I do not understand the purpose of using the inline function, even if some function is not declared inline function, the compiler will perform the same as the code where the inline function is, respectively, both will do the same. And after this question, I have question about recursion, I get it how storage works and purpose of recursion, but if anyone have some code and explanation of that code is not too complicated I would like to write to me here or in messages. Thanks :)
  16. Let's try it, btw. Thanks a lot fr sharing <3 I really appriciate it