Vla_DOS

Untitled

Jan 30th, 2023
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. void convert_to_uppercase(char *input)
  6. {
  7.     for (int i = 0; i < strlen(input); i++) {
  8.         input[i] = toupper(input[i]);
  9.     }
  10. }
  11.  
  12. void center_text(char *input)
  13. {
  14.     int length = strlen(input);
  15.     for (int i = length; i < 50; i++) {
  16.         printf(" ");
  17.     }
  18.     printf("%s\n", input);
  19. }
  20.  
  21. int main()
  22. {
  23.     char input[100];
  24.     printf("Enter a string: ");
  25.     scanf("%[^\n]", input);
  26.     convert_to_uppercase(input);
  27.     printf("Input string: %s\n", input);
  28.     printf("Centered string: ");
  29.     center_text(input);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment