Professional Documents
Culture Documents
Lecture 16 - For Loop (Continued), Nested For Loop, Escape Sequences and Type Casting
Lecture 16 - For Loop (Continued), Nested For Loop, Escape Sequences and Type Casting
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
Escape Sequence
- Characters which are used in string to change the sequence of the string
- Characters
- \t
- adds tab (4-8) space
- \n
- new line
- \r
- return to the starting of the string
- \\
- to print \
- \"
- to print "
- \'
- to print '
Example: Escape sequences
#include <iostream>
using namespace std;
int main(int argc, char ** args){
cout << "This\tis\njust\rfor\\testing\"escape sequences\"";
return 0;
}
Type Casting
- Conversion of one type of data into the other type of data
- 2 types
- Implicit casting
- conversion which is done by the compiler itself
Example: Implicit casting
#include <iostream>
using namespace std;