Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. void checkStr(){
  2.  
  3. printf("Enter sequence of lowercase letters [a-z]:\n");
  4.  
  5. char c =scanf("%c", &c);
  6.  
  7. while (c != '\n')
  8. {
  9.  
  10. //char c = 0;
  11. c = scanf("%c", &c);
  12. int mixed=0;
  13. int cons=0;
  14. int increase = 0;
  15. int decrease = 0;
  16.  
  17. if ((c < 97) || (c > 122) || ((c = scanf("%c", &c)) < 97) || ((c = scanf("%c", &c)) > 122))
  18. {
  19. printf("Your text is invalid\n");
  20. }
  21. else if (c > (c = scanf("%c", &c)))
  22. {
  23. decrease = 1;
  24. }
  25. else if (c < (c = scanf("%c", &c)))
  26. {
  27. increase = 1;
  28. }
  29. else if (c == (c = scanf("%c", &c)))
  30. {
  31. cons = 1;
  32. }
  33. else
  34. {
  35. mixed = 1;
  36. //break;
  37. }
  38. printf("ASCII value of %c = %d\n", c, c);
  39. if ((mixed == 0) && (cons == 0) && (increase == 0) && (decrease == 1))
  40. printf("Your text is deacreasing");
  41. else if ((mixed == 0) && !(cons == 0) && (increase == 1) && (decrease == 0))
  42. printf("Your text is increasing");
  43. else if ((mixed == 0) && !(cons == 1) && (increase == 0) && (decrease == 0))
  44. printf("Your text is constant");
  45. else
  46. printf("Your text is mixed");
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement