Hello YouTubers, I'm Parviz and this is our third video in C++ programming language
In this video I'm going to show you how you can display a string in C++ and also how you
can get input in C++ programming language. So now let me just remove this code from my previous video
Okay now for displaying a string the first thing you need to do is include a string in here
So let me just include and I'm going to include the string in here
Now let me just print a name so in here and you can use like this
You can specify the data type and also you can specify the name like this and now let
me just cout this and cout name and this is end line
Now if I run this, ctrl F5, now you can see we have the string in here, it's my name
Now sometimes you need to get input for example if you want to get input from the user so
let me just show you. This time let me just create string name and I don't want to specify the name
Now in C++ if you see we have learned about the cout so it's used for printing something
in the screen. So let me just say please enter your name and end line
So now using cn you can get input users so let me just write cn and name, I'm going to
add name so I want to get the user input and store that in the name variable and after
that I want to print that in the screen. So now I'm going to just say cout your name is and now you can use class to concat variable
so name like this. So now if I run this, now you can see it's telling me that please enter your name and
if I enter like this and if I hit enter you can see your name is Parviz and press any
key to continue. Let me just add an end line in here and now let me run it again
Now let me write John Doe and if I hit enter you can see your name is John because we have
a space in here and it's not in here. So we'll talk about this later
Ok now so this was a string now let me just create a simple program for example I have
two numbers so int num1 and int num2 like this ok. Now I want to get the numbers, two numbers from the user and I want to sum these two
numbers ok. So let me first write cout and in here I'm going to say that please enter first number
like this, end line and after that I'm going to get the input from the user and store that
in num1 like this ok. So let me just create int sum and num1 plus num2 so I want to add these two numbers ok
Now this was my first number now let me just create for the second number so cout and please
enter second number and let me just end line and now I want to get the second number and
store that in num2 so num2 like this ok. Now after this I have added these two numbers in here and now I want to print the result
in the screen so now I can see so let me just do int sum declare this in here and in here
I'm going to just say sum and I want to num1 plus num2 and now I want to display this so
cout and total let me just write total for the number s and I'm going to add the sum
in here and let me just end line. Ok now let me just run my program so now you can see please enter a number let me enter
5 please enter second number let me enter 2 and now you can see the total for the number
is 7 so like this you can work with the input getting the input from the user thank you
guys if you have any question please let me know I will add a source code to the video
description please like the video and also share the video