Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. void reverse(char *c)
  7. {
  8. int i = 0;
  9.  
  10. while(c[i] != '')
  11. //for(int i = 0; i < 50; ++i)
  12. {
  13. if(c[i] == tolower(c[i]))
  14. c[i] = toupper(c[i]);
  15. else
  16. c[i] = tolower(c[i]);
  17.  
  18. cout << c[i];
  19. ++i;
  20. }
  21. }
  22.  
  23.  
  24. void upper(char *c)
  25. {
  26. int i = 0;
  27. while(c[i] != '')
  28. //for(int i = 0; i < 50; ++i)
  29. {
  30. c[i] = toupper(c[i]);
  31. cout << c[i];
  32. ++i;
  33. }
  34. }
  35.  
  36.  
  37. void lower(char* c)
  38. {
  39. int i = 0;
  40. while(c[i] != '')
  41. //for(int i = 0; i < 50; ++i)
  42. {
  43. c[i] = tolower(c[i]);
  44. cout << c[i];
  45. ++i;
  46. }
  47. }
  48.  
  49. int main (int argc, const char * argv[])
  50. {
  51. char input[50];
  52.  
  53. cout << "Enter a string: ";
  54. cin.getline(input, 50);
  55.  
  56. cout << "nnAfter a call to Upper: ";
  57. upper(input);
  58.  
  59. cout << "nnAfter a call to Lower: ";
  60. lower(input);
  61.  
  62. cout << "nnAfter a call to Reverse: ";
  63. reverse(input);
  64.  
  65. cin.sync();
  66. cin.get(); //To pause the program
  67.  
  68. //cout << "here";
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement