Advertisement
sellmmaahh

OR-postavke2-SumaCifaraUStringu

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