Question
Can anyone help me to solve this problem? Thanks in advance
Assignment 6 Strings Write a program which makes Caesar encryption. Caesar encryption is based on circular shifting of the letters with a given amount. Your program will encrypt the input and it will shift the letters by the given amount (if it passes z, it will continue from a), it will not change spaces ( ). You can assume that no other characters will be entered.

media%2Fe06%2Fe06a3098-4136-471f-8731-ef
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code in C++:

#include<iostream>
using namespace std;
int main(){
    char str[100];
    cout<<"Enter the sentence:";
    cin.getline(str,100);
    int n,length;
    cout<<"Enter number:";
    cin >> n ;
    length=strlen(str);
    int temp,i;
    char ch;
    for(i=0;i<length;i++){
        if(str[i]==' ')
             continue;
        ch=str[i];
        temp=(int)(ch);
        temp=temp+n;
        if(temp>122){
            temp=temp-122;
            temp=temp+96;
            ch=(char)(temp);
            str[i]=ch;
        }
        else if(temp<97){
            temp=97-temp;
            temp=123-temp;
            ch=(char)(temp);
            str[i]=ch;
        }
        else{
            ch=(char)(temp);
            str[i]=ch;
        }
    }
    cout<<"After encryption:"<<endl;
    cout<<str;
}

Output:

CppDroid terminal Stopped Enter the sentence:little quick brown fox j umped over the lazy dog Enter number:4 After encryption

Add a comment
Know the answer?
Add Answer to:
Can anyone help me to solve this problem? Thanks in advance Assignment 6 Strings Write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Could anyone help me solve this problem in C++? Thanks a lot. Develop an OOP program...

    Could anyone help me solve this problem in C++? Thanks a lot. Develop an OOP program to maintain a list of homework assignments. When an assignment is assigned, add it to the list, and when it is completed, remove it. You should keep track of the due date. Your program should provide the following services: • Add a new assignment. • Remove an assignment. • Provide a list of the assignments in the order they were assigned. • Find the...

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

  • Can anyone help me write a C function that goes through an input string and insert...

    Can anyone help me write a C function that goes through an input string and insert spaces(" ")infront and after "<",">","|"? For example: if my input string is: HELLO<WO|RLD>!, the output of the function will be a array like: HELLO < WO | RLD > ! Thanks!

  • Can anyone help me solve this problem plz. Thanks 1- first choices are ( amount of...

    Can anyone help me solve this problem plz. Thanks 1- first choices are ( amount of improvement in his game, golfer, type of equipment used) 2- second choices are (golfer, type of equipment used, amount of improvement in his game) Identify the explanatory variable and the response variable A golfer wants to determine if the type of equipment used every year can be used to predict the amount of improvement in his game The explanatory variable is the The response...

  • Can anyone please help me with the 2 questions below. Thanks in advance: 1. Critically analyse...

    Can anyone please help me with the 2 questions below. Thanks in advance: 1. Critically analyse the role of competitive advantage in supply chain management, and how purchasing influences strategy. 2. Discuss how performance measurement of suppliers improves efficiency and develops competitive advantage, using examples of organisations to illustrate your answer. Thanks

  • Can anyone please help me with the 2 questions below. Thanks in advance: 1. Critically analyse...

    Can anyone please help me with the 2 questions below. Thanks in advance: 1. Critically analyse the role of competitive advantage in supply chain management, and how purchasing influences strategy. 2. Discuss how performance measurement of suppliers improves efficiency and develops competitive advantage, using examples of organisations to illustrate your answer. Thanks

  • Python 3. Can anyone please help me with these two homework using Python 3. Thanks in...

    Python 3. Can anyone please help me with these two homework using Python 3. Thanks in advance 8. Tip, Tax, and Total Write a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15 percent tip and 7 percent sales tax. Display each of these amounts and the total. 9. Celsius to Fahrenheit Temperature Converter Write...

  • can anyone can help me solve this question? It's about magentic flux, thanks! R. Vierminal. =て...

    can anyone can help me solve this question? It's about magentic flux, thanks! R. Vierminal. =て mossm

  • Kindly follow the instructions provided carefully. C programming   Project 6, Program Design One way to encrypt...

    Kindly follow the instructions provided carefully. C programming   Project 6, Program Design One way to encrypt a message is to use a date’s 6 digits to shift the letters. For example, if a date is picked as December 18, 1946, then the 6 digits are 121846. Assume the dates are in the 20th century. To encrypt a message, you will shift each letter of the message by the number of spaces indicated by the corresponding digit. For example, to encrypt...

  • Can anyone please solve this for me in java. Thanks Complete the program below that prints...

    Can anyone please solve this for me in java. Thanks Complete the program below that prints a square. The program will read the size (an integer value) of the square and a character. It will then generate a square with a number of rows and columns that corresponds to size, and where the * character is used for the square border. The provided character will be used for the rest of the diagram. Use the message “Enter size:” and “Enter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT