Write a program to print the following output using loop:
BBBBBBBBB
. BBBBBBB
. . BBBBB
. . . BBB
B
Solution:
#include<iostream.h>
#include <conio.h>
void main()
{
int i , j , k;
for(i=1; i <=5; i++)
{
for(k = 1; k <=5-i; k++)
cout<<" .";
for(j=1; j <= 2*i-1; j++)
cout<<"B";
cout<<endl;
}
getch();
}
No comments:
Post a Comment