Lecture 16
Escape Sequences:
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
cout<<"Newline : \n
";
cout<<"Tab : \t
"<<endl;
cout<<"Backspace : \b
"<<endl;
cout<<"Carriage return : \r "<<endl;
cout<<"Formfeed : \f "<<endl;
cout<<"Single quote : \' "<<endl;
cout<<"Double quote : \" "<<endl;
cout<<"Backslash : \\ "<<endl;
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10
Printing Graphics
Characters:
Code:
#include
<iostream>
#include
<conio.h>
using
namespace std;
int
main (int argc, char *argv[])
{
cout<<"Hex value:";
cout<<"ASCII code run 0:
\x0"<<endl;
cout<<"ASCII code run 1:
\x1"<<endl;
cout<<"ASCII code run 2:
\x2"<<endl;
cout<<"ASCII code run 3:
\x3"<<endl;
cout<<"ASCII code run 4:
\x4"<<endl;
cout<<"ASCII code run 5:
\x5"<<endl;
cout<<"ASCII code run 6:
\x6"<<endl;
cout<<"ASCII code run 7:
\x7"<<endl;
cout<<"ASCII code run 8:
\x8"<<endl;
cout<<"ASCII code run 9:
\x9"<<endl;
cout<<"ASCII code run A:
\xA"<<endl;
cout<<"ASCII code run B:
\xB"<<endl;
cout<<"ASCII code run C:
\xC"<<endl;
cout<<"ASCII code run D:
\xD"<<endl;
cout<<"ASCII code run E:
\xE"<<endl;
cout<<"ASCII code run F:
\xF"<<endl;
cout<<".................";
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10
Decimal to binary code:
#include
<iostream>
#include
<conio.h>
using
namespace std;
int
main (int argc, char *argv[])
{
int a=2;
cout<<"The decimal value is :
"<<a;
cout<<"\nThe binary value is :
";
cout<<a%2;
a=a/2;
cout<<a%2;
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10