The Escape Sequences in C++ - Example program 03
Write a C++ program to print the following shape by using single cout statement with the help of escape sequences.
X
X X
X X X
X X X X
X X X X X
It is very simple program and can be handled by using Escape Sequences "\t" (it is used to insert 8 spaces) and "\n" (it is used to transfer control to the next statement).
See program output:
#include<iostream.h>
#include<conio.h>
main(){
clrscr();
cout<<"X\nX\tX\nX\tX\tX\nX\tX\tX\tX\nX\tX\tX\tX\tX";
}
#include<conio.h>
main(){
clrscr();
cout<<"X\nX\tX\nX\tX\tX\nX\tX\tX\tX\nX\tX\tX\tX\tX";
}
more
from: CS Adventures
0 comments:
Post a Comment