## Friday, March 18, 2011

### \ooo octal number

lets understand the use of \ooo escape sequence with the help of some interesting examples
here ooo is one to three octal digits(0....7) means there must be atleast one octal digit after \ and maximum three..........
1.
int main()
{
char *s="A\0655";
printf("%s",s);
return 0;
}

Output:
A55

Explanation:
its very interesting to know the reason behind such output.......here 065 is the octal notation....... firstly it will get converted in to decimal notation i.e. 53 and it is the ASCII value of char '5' hence at the place of \065 there is 5........................ so the output is A55............

okay,lets understand it with 1 more example.....

2.
int main()
{
char *s="A\035B";
printf("%s",s);
return 0;
}

Output:
A<->B

Explanation:
decimal notation of 035 is 29.................n it is the ASCII value of '<->' char.......... hence the output is A<->B........................

2.
int main()
{
char *s="A\33A";
printf("%s",s);
return 0;
}

Output:
A<-A

Explanation:
decimal notation of 33 is 27.................n it is the ASCII value of '<-' char.......... hence the output is A<-A........................it shows octal number can have two octal digits also.............similarly there can be only 1 octal digit.................

try for different strings......its really amazing.................