Advertisement
Rakibul_Ahasan

Untitled

Mar 22nd, 2021
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define LL long long
  4.  
  5.  
  6. void Operator() {
  7. //getchar();
  8. cout<<"\nEnter the String: ";
  9. char s[20];
  10. gets(s);
  11.  
  12. cout<<"\n"<<"Output: \n";
  13.  
  14. int i=0;
  15.  
  16. while (s[i] != '\0') {
  17. switch (s[i]) {
  18.  
  19. case '=':
  20. if(s[i+1]=='='){
  21. cout<< s[i]<<s[i] << " :equal to operator"<<"\n";
  22. i+=2;
  23. }
  24. else{
  25. cout<< s[i] << " :simple assignment operator"<<"\n";
  26. i++;
  27. }
  28. break;
  29. case '+':
  30. if(s[i+1]=='+'){
  31. cout<< s[i]<<s[i] << " :increment operator"<<"\n";
  32. i+=2;
  33. }
  34. else{
  35. cout<< s[i] << " :addition operator"<<"\n";
  36. i++;
  37. }
  38. break;
  39. case '-':
  40. if(s[i+1]=='-'){
  41. cout<< s[i]<<s[i] << " :decrement operator"<<"\n";
  42. i+=2;
  43. }
  44. else{
  45. cout<< s[i] << " :subtraction operator"<<"\n";
  46. i++;
  47. }
  48. break;
  49. default:
  50. //printf("\n Not a operator");
  51. i++;
  52. }
  53. }
  54.  
  55. }
  56.  
  57.  
  58. int main()
  59. {
  60. cout<<"Take input multi time: ";
  61. int tc;
  62. cin>>tc;
  63. getchar();
  64. while(tc--){
  65. Operator();
  66. }
  67. return 0;
  68. }
  69.  
  70. /*
  71. int y = a+b;
  72.  
  73. y++;
  74.  
  75. if(x==m && x==n) y=y-1;
  76.  
  77. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement