Computer Science, asked by vishal5040, 1 year ago

(c) Write a macro to display string "Cobol" in the following pattern:
С
со
сов
сово -
сово
сов OL
сово
сов

Answers

Answered by Tilaknahar6102005
5

A macro to display string is COBOL

is the pattern

Answered by anandinfotech
4

Answer:

/* Program to display the string as given in the problem*/  

# include<stdio.h>  

# define  

LOOP      for(x=0; x<5; x++) \  

   {    y=x+1; \  

printf(“%-5.*s\n”, y, string);  } \  

  for(x=4; x>=0; x--)\  

   {y=x+1;\  

printf(“%-5.*s \n”, y, string); }

main()  

{  

int x, y;  

static char string[ ] = “COBOL”;  

printf(“\n”);  

LOOP;  

}  

Explanation:

When the above program is executed the reference to macro (loop) is replaced by the  

set of statements contained within the macro definition.    

OUTPUT  

C  

CO  

COB  

COBO  

COBOL  

COBOL  

COBO  

COB  

CO  

C  

Similar questions