Write a macro to display the string COBOL in the following pattern. C CO COB COBO COBOL

Write a macro to display the string COBOL in the following pattern.
C
CO
COB
COBO
COBOL

Ans.
#include
#include
void main()
{
int i,j;
char arr[5]={‘c’,’o’,’b’,’o’,’l’};
clrscr();
for(i=0;i<=4;i++)
{
for(j=1;j<=i-1;j++)
{
printf(“%s”,arr[i]);
}
printf(“n”);
}
getch();

}

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.