Untitled


SUBMITTED BY: Guest

DATE: Sept. 30, 2014, 10:18 p.m.

FORMAT: C++

SIZE: 509 Bytes

HITS: 1530

  1. #include <stdio.h>
  2. #define N 16
  3. // don't forget to account for the \0 at the end
  4. void main()
  5. {
  6. char string[N];
  7. int i, sum=0;
  8. printf("Write a sentence with . between words: \n");
  9. scanf("%s", string);
  10. for (i = 0; i<N-1; i++)
  11. {
  12. if (string[i] == '.')
  13. {
  14. printf("The geometria is %d\n",sum);
  15. sum = 0;
  16. }
  17. else
  18. {
  19. sum+= (int)string[i];
  20. }
  21. }
  22. printf("The geometria is %d",sum);
  23. getch();
  24. }

comments powered by Disqus