Hello… People with Happy Faces.. Just right after finishing the Exams and having a Leisure time.. :)
How you doing guys.. Having fun..!! I know.. Batch trips , Vacation etc,etc.. Well… me too.. :)
We had to pause our C++ programming post series because I had semester exams for almost an entire month from 24th of May to 17th of June.. And You know what.. the exam was my B'day gift from KDU.. Yeah people.. It was on my Birthday.. 24th of May.. Yey.. Happy birth day for me..!! :)
However I put some posts to discuss the model papers before the exam..
So.. Now we have enough time to continue our amazing post series ;) Let’s start again..
Last time we ended our post with explaining the cout in c++.
Cout is use to display or print anything on console.
You can print
Remember the last time, we printed your name and your address..?? This time lets discuss some techniques we can use to print text using cout. ( By print I meant displaying it on the console. Not actually printing it using a printer!!)
When you print texts or words using cout, you can’t print some characters as output.
For example
Cout<<”Don’t come late. Did you miss the bus today? ”;
If you try to print this you will probably end up in a error. Reason is that you have ? question mark and ‘ single quote to print.
Now you have a problem , how to print “” or ? ‘ these.. Right..? Well, you have a way to do this. It is called "escape sequence" .
You can type any of those symbols right after a backward slash, then there will be no error.
Ex:-
cout<<” Don\’t come Late. Did you miss the bus today\? ”;
Cout<<” \”Here Im Using Double quotes with in double quotes.. ;)\” ”;
Here's a list of Escape Sequence.
Try this list in your code.
Specially this \t – tab and \b-backspace part.
Ok.. I will Stop this little post from here by leaving you some exercises. Please do these and I promise you to discuss them in my next post..
Ex 01:
Try to print letters like this in the terminal.
P.S
My Fellow readers. Thanks for staying with the blog. Now You can follow my blog by subscribing, using your email address. You can see it on top of the right side-bar. And please don’t be hesitate to ask any question about anything. See you in my next post… Let's talk about variables in next post..
Next Post >>>
- any text
- any value of a variable
- result of any operations with variables
Remember the last time, we printed your name and your address..?? This time lets discuss some techniques we can use to print text using cout. ( By print I meant displaying it on the console. Not actually printing it using a printer!!)
When you print texts or words using cout, you can’t print some characters as output.
- “ - double quotes
- ‘ – single quotes
- \ - backward slash
- ? – question marks
For example
Cout<<”Don’t come late. Did you miss the bus today? ”;
If you try to print this you will probably end up in a error. Reason is that you have ? question mark and ‘ single quote to print.
Now you have a problem , how to print “” or ? ‘ these.. Right..? Well, you have a way to do this. It is called "escape sequence" .
You can type any of those symbols right after a backward slash, then there will be no error.
Ex:-
cout<<” Don\’t come Late. Did you miss the bus today\? ”;
Cout<<” \”Here Im Using Double quotes with in double quotes.. ;)\” ”;
Here's a list of Escape Sequence.
Try this list in your code.
Specially this \t – tab and \b-backspace part.
Ok.. I will Stop this little post from here by leaving you some exercises. Please do these and I promise you to discuss them in my next post..
Ex 01:
**
****
******
********
**********
************
Write a program to print above triangle.
Ex 02:
****
******
********
**********
************
Write a program to print above triangle.
Ex 02:
Try to print letters like this in the terminal.
P.S
My Fellow readers. Thanks for staying with the blog. Now You can follow my blog by subscribing, using your email address. You can see it on top of the right side-bar. And please don’t be hesitate to ask any question about anything. See you in my next post… Let's talk about variables in next post..
Next Post >>>