Advertisement
Divyansh_Chourey

word frame

May 10th, 2024
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main(){
  4.     /*
  5.     *******
  6.     *Hello*
  7.     *World*
  8.     *of   *
  9.     *c    *
  10.     *print*
  11.     *******
  12.     */
  13.     char s_arr[10][10];
  14.     int n;
  15.     printf("enter the number of words: ");
  16.     scanf("%d", &n);
  17.     printf("Enter the strings: \n");
  18.     for(int x=0; x<n; x++){
  19.         scanf("%s", s_arr[x]);
  20.     }
  21.     int max_char = 1;
  22.     for(int i=0; i<5; i++){
  23.         if(strlen(s_arr[i])>max_char){
  24.             max_char = strlen(s_arr[i]);
  25.         }
  26.     }
  27.     for(int a=0; a<12; a++){
  28.         printf("*");
  29.     }
  30.     printf("\n");
  31.  
  32.     for(int b=0; b<n; b++){
  33.         printf("*%-10s*\n", s_arr[b]);
  34.     }
  35.  
  36.     for(int a=0; a<12; a++){
  37.         printf("*");
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement