-3

I am making a program where I take a single character and encode it. Here is my assignment on the left with my code on the right. I am forgetting what I need to do to get the encrypted result. Code here

2 Answers2

1

The encrypted character is: (int)char_to_encrypt * multiplier + adder.

You need to convert the character to its ASCII code then multiply it by the multiplier then get the result and add the adder to it.

Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36
0

The encrypted result is calculated in 3 operations:

  1. Get the ASCII value from the Symbol (this answer may help you do that),
  2. multiply the ASCII value you got by the Multiplier,
  3. add the Adder value.

You've got the inputs, perform those operations on the inputs to get the encrypted result.

An aside, you may want to reconsider the name of the char you are using for the 'character', char D;, as this is merely an example of a symbol the user may enter. Instead consider char character; or something more generic so that when you take its ASCII value, it represents its corresponding symbol.

Community
  • 1
  • 1