C++ this is the code i am having the following error in the png #include #include #include #include using namespace std; // Global constants const int MaxWordSize = 81; // 80 characters + 1 for NULL // Given an array of characters and a shift value: // shift each character in the original text by some amount, // storing the result into the shiftedText array. // Remember: Wrap around at the end of the alphabet. // *** In the line below you must supply the function // return type and the parameter(s) *** void shiftTheText(char startingText[], int shiftVal, char shiftedText[]) { // Loop through each character in the C string, startingText // When the character is an alphabetic character, // shift it by adding the shift value. // Then store the resulting character in its proper spot // in the shiftedText C string. size_t a = strlen(startingText); for(int i=0; i122) temp-=26; shiftedText[i] = (char)temp; } } int main() { // Initialize the variables char startingText[ MaxWordSize]; char shiftedText[ MaxWordSize]; cout << "Enter some lower-case text: "; cin >> startingText; for( int shiftValue = 0; shiftValue < 26; shiftValue++) { // In the function call below you need to pass the starting text array, the shift value, and the shifted text array. shiftTheText(startingText,shiftValue,shiftedText); cout << "Shifting " << setw( 2) << shiftValue << " gives: " << shiftedText << endl; } return 0; // Keep C++ happy }// end main()
C++
this is the code i am having the following error in the png
#include <iostream>
#include <iomanip>
#include <cctype>
#include <string.h>
using namespace std;
// Global constants
const int MaxWordSize = 81; // 80 characters + 1 for NULL
// Given an array of characters and a shift value:
// shift each character in the original text by some amount,
// storing the result into the shiftedText array.
// Remember: Wrap around at the end of the alphabet.
// *** In the line below you must supply the function
// return type and the parameter(s) ***
void shiftTheText(char startingText[], int shiftVal, char shiftedText[])
{
// Loop through each character in the C string, startingText
// When the character is an alphabetic character,
// shift it by adding the shift value.
// Then store the resulting character in its proper spot
// in the shiftedText C string.
size_t a = strlen(startingText);
for(int i=0; i<a; i++){
int temp = (int)startingText[i];
temp+=shiftVal;
if(temp>122)
temp-=26;
shiftedText[i] = (char)temp;
}
}
int main()
{
// Initialize the variables
char startingText[ MaxWordSize];
char shiftedText[ MaxWordSize];
cout << "Enter some lower-case text: ";
cin >> startingText;
for( int shiftValue = 0; shiftValue < 26; shiftValue++) {
// In the function call below you need to pass the starting text array, the shift value, and the shifted text array.
shiftTheText(startingText,shiftValue,shiftedText);
cout << "Shifting " << setw( 2) << shiftValue << " gives: " << shiftedText << endl;
}
return 0; // Keep C++ happy
}// end main()
Trending now
This is a popular solution!
Step by step
Solved in 2 steps