Can someone please help me where to begin on this problem... I don't want answers, just some guidance:
I have to make a program that reads a 4 digit integer: and encrypt it with a calculation: then swap 1st digit with 3rd, swap 2nd digit with 4th and print the integer; then write another program that inputs the encrypted 4 digit int and decrypt from the original number.
I want to use rand() and srand() to generate the numbers. But, I am also considering an array and create constant numbers to input: I thought that by scrammbling the numbers on input that this would automatically encrypt the numbers... (?): I am confused on where to begin to solve this problem (I do understand the calculation but am stuck on the encryption and decryption issue). Also, I think this problem needs to use a nested approach.... please tell me if I am on the right track: or can you please give me some direction or tell me if I am thinking correctly! I just need some clarity... thank you.

12 Years
Discussion Span
Last Post by letmec

So wats problem in it just swap the digits....that the encrypted one.....and then again swap it back to decrypt

just convert the integer to strint using itoa() function, and then you can easly swape the digit-character. and then conver the this encrypted string back to integer using atoi() function. Visa-versa with decryption.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.