top of page
Code writing style
Each programming language has a different writing style. C Plus Plus is considered one of the high-performance languages, and its writing style is difficult compared to other languages, but it is an excellent language in which you can develop most applications and it has no limits.
the beginning
First we will call:<include<iostream#
This library will call the input and output and without it the code will not work
Second, we will call:using namespace std
When we add this portlet, we will not need to write the portlet name::std.
We can easily shorten it as: the portal is like a library that makes it easy for us to write entries.
Third, we will call:{}()int main
It is the main function in which we can pass all the code and it is the first function that the program calls and executes
We put all the commands inside the curly brackets {}
middle
Here we will put all the code that will be in the curly brackets of the main function {here}()int main
I will now explain some programming commands
We have previously explained variables (int, float....), but what is the method for writing variables in the compiler?
Variables are defined in the same way
NB: Variable names cannot contain a space
1- First: variable name int secondly: We call it age Third: Variable value 23 So the way to define it is as follows: ;int age=23
2- First: variable name string secondly: We name it name Third: variable value "soud" The way to define it becomes as follows:
;string name="black
3- First: variable name float secondly: We call it grade Third: Variable value 9.5 So the way to define it is as follows:
;float guard=9.5
4- First: variable name bool secondly: We call it pass Third: The value of the variable is true So the way to define it is as follows:
;bool pass=true
5- First: variable name char secondly: We call it gradeletter Third: value of variable 'A' So the way to define it is as follows: ;'char gradeletter='A
cout
There is a command called bcout It prints. Its writing style is like this:
;"cout<<"hello everyone
We put firstprint commandcout then we putMy sign is less than Then we putDouble quotation marks Because then textThe text that we want to print thenWe end the command with a flag;
We can use the print command to print the variables after defining them, and they look like this:
;cout<<age<<end
;"cout<<age<<"\n
;endl Meansend of line
\n It also means the end of the line, but if it is placed alone in Figb Double quotation marks
;"cout<<pass<<"\t
t\ Come on But if you put it alone figb Double quotation marks
Code: First try it yourself and then see the codehttps://onlinegdb.com/6bA_JckuA
the end
We put a signreturn 0 Let's tell the program that we have finished placing the code
bottom of page