Answer to Question #57383 in C++ for Mary Rose Vergara

Question #57383
rotate the word computer by 1 results is rCompute. If the input is 3, terCompu is the output.
1
Expert's answer
2016-01-20T07:19:41-0500
#include <iostream>
#include <string>

using namespace std;

int main() {
string s = "Computer";

int rot = 0;

cin >> rot;

for (int i = 0; i < s.length(); i++) {
cout << s[(i - rot) % s.length()];
}
return 0;
}

Result.
1
rCompute

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS