Answer:
52 5,
Explanation:
Allison is writing a program in Java and keeps getting an error. Which line of code is causing the error?
A. Int a = 0, b = 3, c;
B. for(i = 0, i <= 13, i++) {
C. c = (a * 2) + i;
D. System.out.println(c);
}
B will cause an error.
Allison needs to declare a type for variable i and use semi-colons.
The for statement should be for(int i = 0; i <=13; i++){
Create a new program with a struct, Data, that contains: an int a char[80] Write a function newData(char[]), that takes char[] as a parameter
Answer:
#include <iostream>
#include <cstring>
using namespace std;
struct Data {
int userId;
char name[80];
}
void newData(string data char[]){
int counts= 0;
struct Data name;
data.userId = ++counts;
data.name = char[];
cout<< data.userId << "\n"<< data.name ;
}
int main( ) {
char myName;
string mydata;
cin>> myName;
cin>> mydata;
newData( myName, mydata);
}
Explanation:
The c++ source code above stores its data in a struct called "Data". The function newData dynamically creates new data from the struct defined.
Write a script that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar cipher.
The script should work for any printable characters. An example of the program input and output is shown below:
Enter a message: Hello world!
Enter the distance value: 4
Output: Lipps${svph%
Answer:
def encrypt_text(text,value):
encoded = ""
for i in range(len(text)):
char = text[i]
if (char.isupper()):
encoded += chr"po"ord'po'char'pc' + value -65'pc' % 26 + 65'pc'
else:
encoded += chr'po'ord'po'char'pc' + value -97'pc' % 26 + 97'pc'
return encoded
plaintext = input("Enter sentence of encrypt: ")
dist_value = int(input("Enter number: "))
encrypted = encrypt_text(plaintext, dist_value)
print(encrypted)
Explanation:
The python program above is a Ceasar cipher implementation. The encrypt_text function is defined to accept text input and a distance value, which is used to encrypt the plaintext.
The user can directly input text and the distance value from the prompt and get the encrypted text printed on the screen.