Monday, 6 June 2016

Escape Sequences and ASCII Values


Escape Sequences:

Escape Sequence
Description
\n
New Line
\t
Horizontal Tab (Print 8 spaces)
\b
Back space
\f
New Page (Form feed)
\a
Audible Bell
\r
Carriage Returns (Bring The Positon of Cursor to initial Position)
\v
Vertical Tab
\\
Prints Slash



How to use them?

To print any of the Escape Sequence you will write in the following way as one is being shown for you:
printf (“\n”);//For C
cout<<”\n”;//For C++
Key Point:

  •          Most commonly use escape sequence are first three while other are rarely used.
  •          In C++ Usually we use “endl” to change the line. For example: cout<<”1”<<endl<<2;

Now let’s see how they works one Example Program is being written for you below.

Example:



How to print above sequence(Triangle)  using escape sequences without using loop or recursion ?


1
2
3
4
5
#include<stdio.h>
int main()
{
                printf("   *\n  **\n ***\n****\n");
}


Before 1st Star three Manually Spaces are given then before two stars of the 2nd line two spaces are manually written then before three stars in 3rd line manually print one space.

ASCII Codes

What are ASCII Codes?

ASCII(American Standard Code for Information Interchange) Codes are printable character codes among them 32-177 are commonly Used .The consist of Numbers ,Characters, Letters and few Symbols ever character on your Keyboard can be find in ASCII Codes Tables .
Table of ASCII Code is below:


Credits For the ASCII Code Table :www.lookupTables.com


How to use them?

printf(“%c”,65);//For C
cout<<(char)65;//For C++
This will print the character values of the integer (Decimal) i.e. A. Similar Any Decimal value from the above can be printed into character by this way.


How to Print the Decimal Value of ASCII Code?

printf(“%d”,’A’);//For C

cout<<(int)’A’;//For C++

We want you to practice and keep on practicing these steps and we hope that you have understood all the steps we mentioned in this article. Give us your feedback by clicking here or comment down below. Thanks for reading!


Assignments:
You have an assignment! Download this document and solve the questions for your practice. Send us your solution .c or .cpp files through The QuickSEnd down below.



The QuickSEnd:


No comments:

Post a Comment