Advertisement
sellmmaahh

Zad1

Aug 12th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int suma_cifara(char* string)
  4. {
  5.     int suma = 0;
  6.    
  7.     while(*string != 0)
  8.     {
  9.         if(*string >= '0' && *string <= '9')
  10.         {
  11.             suma += (*string - '0');
  12.         }
  13.        
  14.         string++;
  15.     }
  16.    
  17.     return suma;
  18. }
  19.  
  20. int main()
  21. {
  22.     char string[] = "hrk45ljus21";
  23.    
  24.     printf("%d", suma_cifara(string));
  25.    
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement