Advertisement
Jkljk

programa que recebe uma string e remove suas vogais

Sep 14th, 2020
1,505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. /* Crie um programa com uma função que recebe uma string A de tamanho
  2. máximo 50, fornecida pelo usuário. A função deve, então, remover todas as
  3. vogais (substituindo-as por espaços em branco) e retornar esta nova string
  4. para a função main. Por fim, deve-se imprimir em uma linha a string A sem
  5. vogais e na linha seguinte a string A com vogais.
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #define tam 50
  11.  
  12. int removeVogal(char A[tam])
  13. {
  14.     int i, tamanho = strlen(A);
  15.     for(i=0; i<tamanho; i++)
  16.     {
  17.         if(A[i]=='a' || A[i]=='A')
  18.         {
  19.             A[i]= ' ';
  20.         }
  21.         if(A[i]=='e' || A[i]=='E')
  22.         {
  23.             A[i]= ' ';
  24.         }
  25.         if(A[i]=='i'|| A[i]=='I')
  26.         {
  27.             A[i]= ' ';
  28.         }
  29.         if(A[i]=='o' || A[i]=='O')
  30.         {
  31.             A[i]= ' ';
  32.         }
  33.         if(A[i]=='u' || A[i]=='U')
  34.         {
  35.             A[i]= ' ';
  36.         }
  37.     }
  38. }
  39.  
  40. int main(){
  41.     char frase[tam], aux[tam];
  42.     puts("digite uma frase de ate 50 caracters: \n");
  43.     scanf("%[^\n]s",&frase);
  44.     getchar();
  45.     for(int i=0;i<strlen(frase);i++){
  46.         aux[i]=frase[i];
  47.     }
  48.     removeVogal(frase);
  49.     printf("\n%s\n%s", frase, aux);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement