Guest User

Untitled

a guest
Jun 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #define MAX 50
  4.  
  5. int main(void){
  6. char str[MAX] = "0"; //initialise 1st char for the loop
  7. int i;
  8. printf("Enter your sentence, at most 50 character: n");
  9. for(i = 0; str[i] != 'n'; i++){ //terminates upon n
  10. str[i] = getchar();
  11. putchar(str[i]);
  12. }
  13. return 0;
  14. }
  15.  
  16. #include <stdio.h>
  17. #include <ctype.h>
  18. #define MAX 50
  19.  
  20. int main(void){
  21. char str[MAX] = "0"; //initialise 1st char for the loop
  22. int i;
  23. printf("Enter your sentence, at most 50 character: n");
  24. for(i = 0;; i++){ //terminates upon n
  25. str[i] = getchar();
  26. putchar(str[i]);
  27. if(str[i] == 'n')
  28. break;
  29. }
  30.  
  31. return 0;
  32. }
Add Comment
Please, Sign In to add comment