Advertisement
fahamidur

Untitled

Dec 6th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void upper_string(char []);
  4.  
  5. int main()
  6. {
  7.    char string[100];
  8.    
  9.    printf("Enter a string to convert it into upper case\n");
  10.    gets(string);
  11.    
  12.    upper_string(string);
  13.    
  14.    printf("The string in upper case: %s\n", string);
  15.      
  16.    return 0;
  17. }
  18.  
  19. void upper_string(char s[]) {
  20.    int c = 0;
  21.    
  22.    while (s[c] != '\0') {
  23.       if (s[c] >= 'a' && s[c] <= 'z') {
  24.          s[c] = s[c] - 32;
  25.       }
  26.       c++;
  27.    }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement