Guest User

Untitled

a guest
Apr 11th, 2019
227
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.  
  3. int function(char[5]); //Здесь определяем функцию до реализации - своего рода контракт
  4.  
  5. int main() {
  6.  
  7.     char temp[5] = "12345";
  8.    
  9.     printf("sum of arr = %d", function(temp));
  10.    
  11.     return (0);
  12. }
  13. //реализуем, придерживаясь определения
  14. int function(char _arr[5]) {
  15.     int result = 0;
  16.     int i = 0;
  17.     for (; i < 5; result += _arr[i++] - '0')
  18.         ;
  19.     return result;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment