I am trying to perform some custom operation but I noticed the following error.
While calculating the value of t
, I get desired output but for s
I am getting negative values for no reason.
#include <bits/stdc++.h>
using namespace std;
int main()
{
char s = 'r';
char temp1 = s;
char t = 'a';
char temp2 = t;
s = (int(temp1) % int(96)) + (int(s) % int(96)) + 96;
cout << int(s) << " ";
t = (int(temp2) % int(96)) + (int(t) % int(96)) + 96;
cout << int(t) << endl;
}
I have to use this logic elsewhere in a bigger program, I am getting the same error in both the cases
Output -124 98
I don't understand why -124 is begin printed