Advertisement
weldisalves

Lista 04 - exercício 17

Jun 21st, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define MAX 100
  4.  
  5. //17. Exiba a quantidade de caracteres do nome do usuário.
  6.  
  7. int main()
  8. {
  9.     char nome[MAX];
  10.     int i,cont=0;
  11.  
  12.     printf("\n Digite um nome: ");
  13.     __fpurge(stdin);
  14.     fgets(nome,MAX,stdin);
  15.  
  16.     for(i=0;i<strlen(nome);i++)
  17.     {
  18.         if((nome[i]>= 'a' && nome[i]<='z')||(nome[i]>='A'&&nome[i]<='Z'))
  19.         {
  20.             cont++;
  21.         }
  22.     }
  23.  
  24.     printf("\n Tamanho do nome: %d",cont);
  25.  
  26.     getchar();
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement