ProAnswers.org

Write a C program to print “WELCOME” by using different formats of initialization of array?

#include

#include 

#include 

void main() 

{ 

char arr1[9]={„W‟,‟E‟,‟L‟,‟‟,‟C‟,‟O‟,‟M‟,‟E‟,‟\0}; 

char arr2[9]=”WELCOME”; 

char arr3[9]={{ „W‟},{‟E‟},{‟L}‟,{‟ ‟},{‟C‟},{‟O‟},{‟M‟},{‟E‟}}; 

clrscr(); 

printf(“

array1=%s:”, arr1);

printf(“

array2=%s:”, arr2);

printf(“

array3=%s:”, arr3);

getch(); 

} 

Output: 

Array1=WELCOME 

Array2=WELCOME 

Array3=WELCOME