fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int countch=0;
  6. int countwd=1;
  7.  
  8. printf("Enter your sentence in lowercase: ");
  9. int ch='a';
  10.  
  11. while(ch!='\n')
  12. {
  13. ch=getchar();
  14. if(ch==' ')
  15. countwd++;
  16. else
  17. countch++;
  18. }
  19.  
  20. printf("Words = %d\n",countwd);
  21. printf("Characters = %d\n",countch-1);
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 1724KB
stdin
i need help

stdout
Enter your sentence in lowercase: Words = 3
Characters = 9