So , guys in my previous tutorial i explained what are libraries , and what is printf and what it does etc..
today i am going to explain what is a escape sequence ..!!well , about that ..!!
when we need to give space or change new line for our output , we use escape sequence …!!
there are lots of escape sequence , i will show you only 2 of them , i.e important ..!!!
But first , let’s create our program here then in turbo c ..!!
Okay , when you run this code in a compiler it will show you this msg , but what if you want to write more than one msg in output ?? ,#include<stdio.h>#include<conio.h>void main(void){clrscr();printf("Hello world , this is Umair Ali ^_^ ");getch();}
well for that you can use a escape sequence ” \n ” , black slash “n” ..!!
but first let’s run this program ..!!!
as you can see , when we run this code and the output we get doesn’t have any space ..!!!
neither a new line …
so this is where a escape sequence comes ..
let’s 1st check , blackslah n i.e “\n”…
well , we can do it via double backslash “n ” i.e “\n\n”
Demo time ..
so i can put any amount of backslash “n ” ..!!
NOw we can do this with only one printf as well let’s see how ..!! , i will omit the sec printf ..
did you see ? , so the codes would be like :
i hope u get the point thought -_- …
let’s move to sec escape sequence , i.e backslah t , “\t” ..
Now this escape sequence , will give a space in your out put …
but first let’s run this program ..!!!
as you can see , when we run this code and the output we get doesn’t have any space ..!!!
neither a new line …
so this is where a escape sequence comes ..
let’s 1st check , blackslah n i.e “\n”…
Now the output’s sec line in on another line .. !! anyways what I want to change another line ??#include<stdio.h>#include<conio.h>void main(void){clrscr();printf("Helloworld ,this is Umair Ali ^_^ ");printf("\nI am Nothing without my ALLAH");getch();}
well , we can do it via double backslash “n ” i.e “\n\n”
Demo time ..
so i can put any amount of backslash “n ” ..!!
NOw we can do this with only one printf as well let’s see how ..!! , i will omit the sec printf ..
did you see ? , so the codes would be like :
</>
just to make our code a little bit of short ..!! anyways …#include<stdio.h>#include<conio.h>void main(void){clrscr();printf("Hello world , this is Umair Ali ^_^\n\n\ni am nothing without my ALLAH");getch();}
i hope u get the point thought -_- …
let’s move to sec escape sequence , i.e backslah t , “\t” ..
Now this escape sequence , will give a space in your out put …
Demo time .. :D.
i hope you saw the output … and notice that there was a space ..
so the codes would be like …:
</>
~Try it out from here , practice makes man perfect ^_^ ..#include<stdio.h>#include<conio.h>void main(void){clrscr();printf("Hello world , this is Umair Ali ^_^\t\t\tI am Nothing without my ALLAH");getch();}
Hope you got this tutorial in your heads …
i hope this would help …!!!
Post a Comment
0Comments