1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
rjkz [21]
3 years ago
8

Write a program that encrypts and decrypts a string of characters. Use a char array for this, not the string class. The maximum

length of a string input to the program will be 200 characters. The input may contain blanks and other whitespace. Your program must request a c-string from the user and encrypt it as described below. If the user enters a single asterisk as the only thing on a line, the program should stop. Otherwise, encrypt the string, then display the encrypted version. Decrypt it using the inverse of the algorithm below and display the result. This should be the original string. Then go back and request another string.
Computers and Technology
1 answer:
dem82 [27]3 years ago
3 0

Answer:

C++ code for encryption is given below

Explanation:

#include <iostream>

using namespace std;

//functions to encrypt and decrypt

void encrypt(char str[]);

void decrypt(char str[]);

int main(){

char str[200];

bool done = false;

while(!done){

cout << "Enter a string (enter * to stop): ";

cin.getline(str, 200);

if(str[0] == '*' && str[1] == '\0')

done = true;

else{

encrypt(str);

cout << "Encrypted: " << str << endl;

decrypt(str);

cout << "Decrypted: " << str << endl;

}

cout << endl;

}

}

void encrypt(char str[]){

int i = 1;

for(int j = 0; str[j] != '\0'; j++){

str[j] += i;

i++;

if(i == 11)

i = 1;

}

}

void decrypt(char str[]){

int i = 1;

for(int j = 0; str[j] != '\0'; j++){

str[j] -= i;

i++;

if(i == 11)

i = 1;

}

}

You might be interested in
For activities with output like below, your output's whitespace (newlines or spaces) must match exactly. See this note. Jump to
Vinvika [58]

Answer:

The program to this question can be given as:

Program:

#include<stdio.h>//include header file

int main() //defining main method

{

printf("Hello..! and please vote the answer."); //print value.

return 0;

}

Output:

Hello..! and please vote the answer.

Explanation:

In the given question some information is missing that is the message to be printed, In this code assume some message to be displayed, and the description to the above code as follows:

  • In the above code firstly header file is included for using a basic function like print method, input method, etc.
  • In the next line main method is defined, inside the main method a print function is used in this function a message is passed with a double-quote ("'). When the code will execute it will print the message that is given in the output section.

5 0
3 years ago
Which is the correct formula to add the values in cells A1 and B1? A. SUM(A1+B1) B. =SUM(A1+B1) C. =SUMA1+B1 D. A1+B1
galina1969 [7]
D I'd the answer to the problem
4 0
3 years ago
Read 2 more answers
Since cam systems regulate and self-mange the manufacturing process, you classify them as
Anna007 [38]

Answer:

The CAM means Computer-Aided Manufacturing, and it monitors as well as manages on the self basis the complete manufacturing process, and hence it is being categorized as the Programmable Automation, that is responsible for the production of the products in various batches. It is in a real sense an Automated Manufacturing.

Explanation:

Please check the answer section.

3 0
3 years ago
You are embedding a video in your Webpage. What three formats should you specify in the source
Bogdan [553]

Answer:

d

Explanation:

3 0
3 years ago
What is a common source of connection problems with ethernets?
Katarina [22]
B) the auto-sensing mechanism
4 0
3 years ago
Read 2 more answers
Other questions:
  • According to many experts how often should files be backed up
    12·1 answer
  • I don't understand question how do I work it out?
    7·2 answers
  • Which computer program did these companies use? fb, Microsoft, Google, LinkedIn​
    10·1 answer
  • You use worksheets to perform calculations. How do you perform these calculations? ______ are used for performing calculations i
    12·2 answers
  • What width would you choose for the pdf?
    12·1 answer
  • Which of the following represents the TCP/IP four-layer reference model? Group of answer choices Application, Internet, transpor
    11·1 answer
  • Why might the government censor what its citizens see on the internet?
    13·2 answers
  • What is the protocol for getting to the Web?
    9·2 answers
  • A _____ focuses on creating software systems like tools, utilities, antivirus programs, and operating systems.
    12·2 answers
  • your organization has decided to use dhcp for ipv6. you want all windows 10 systems using ipv6 to get all of their tcp/ip inform
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!