Programming | C++ | C++ Basics | C++ For
Beginners
c plus plus is a popular programming language introduced by john
straw Strom in the year 1979. It is general purpose case sensitive
language and it is called pre-compiled language. It contains both
features of high level and low-level language. C plus plus supports
procedural programming and functional programming as well.
There are different types of data type that acts as a keyword
which is responsible to define a variable. The syntax of strings
contains a collection of characters surrounded by double quotes
for example here string is the type str is the name of the string
and coffee is the value that is assigned to the string. For loop for
loop is the repetition control structure that allows us to repeat a
block of code for a fixed number of times instead of repeating the
same code again and again. Another type of loop is while loop
while loop is used in c plus are group of statements that are
designed to perform a specific task. functions in c and c plus allow
us to write a code inside the function and then we can use that
code every time when we need it by mocking the function.
We have to use if condition because we want to find the even
elements and the odd elements and for that we have to include if
condition so we 'll write if array of i mod 2 that is if an element on
dividing by 2 gives 0 as a remainder then it will it is even element
so we'll increment the even variable this which we have written 0
will increment over here okay so in this question we have used
array for loop and if else so now let 's try some other example.
We will print the elements from 1 to 20 using while loop and with
the help of function so first of all we 'll start with intermittent and
inside int main will simply call or invoke the function by writing
the name of the function print function. In order to give some
space between each element while printing we have used double
quotes with the space between them. Get line c in is used to take
the input of a string and s is the name of the string. Now we will
print another message saying that you have entered now here
we'll print the string so next line and then okay now we 'll do
some operations likes dot pushback this will add an element at
the end of the. string. There are some more examples on each of
these topics we have covered.