Question: This C++ program is supposed to shift letters a certain amount. For example: 13 Hello, Jack shifts to ----> Uryyb, Whpx. There is an error
This C++ program is supposed to shift letters a certain amount. For example: 13 Hello, Jack shifts to ----> Uryyb, Whpx.
There is an error though. It converts every letter to g and I'm not sure why.
Here is the code: #include
#include
#include
using namespace std;
int main(int argc, char * argv[])
{
int c ;
int shift = atoi(argv[1]) ;
c = tolower(cin.get()) ;
while (!cin.eof())
{
if(isalpha(c))
{
c = 'a';
c += shift;
c %= 26;
c += 'a';
}
cout.put(c);
c = tolower(cin.get());
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
