Page 1 of 1

What will be the output of the following C++ code?

Posted: Wed Jul 13, 2022 7:40 pm
by answerhappygod
#include <cmath>
#include <iostream>
using namespace std;
void Cipher(string str)
{
int r, c;
for (int i = 0; str; i++)
{
 
r = ceil((str - 'a') / 5) + 1;
 
 
c = ((str - 'a') % 5) + 1;
 
 
if (str == 'k')
{
r = r - 1;
c = 5 - c + 1;
}
 
 
else if (str >= 'j')
{
if (c == 1)
{
c = 6;
r = r - 1;
}
c = c - 1;
}
cout << r << c;
}
cout << endl;
}
 
int main()
{
string str = "nsit";
Cipher(str);
}
a) 33344244
b) 44332434
c) 33432444
d) 11444323