Write an interactive c program that will encode or decode a
line of text. To encode a line of text, proceed as follows:
Convert each character, including blank spaces, to its
ASCII equivalent.
Generate a positive random integer. Add this integer to the
ASCII equivalent of each character. The same random integer
will be used for the entire line of text.
Suppose that N1 represents the lowest permissible value in
the ASCII code, and N2 represents the highest permissible
value. If the number obtained in step 2 above exceeds N2,
then subtract the largest possible multiple of N2 from this
number, and add the remainder to N1. Hence the encoded
number will always fall between N1 and N2, and will
therefore always represent some ASCII character.
Display the characters that correspond to the encoded ASCII
values.
The procedure is reversed when decoding a line of text. Be
certain, however, that the same random number is used in
decoding as was used in encoding.
Answer / sss
#include<iostream.h>
#include<string.h>
void main()
{
char str1[]="Testing";
char str2[40];
strcpy(str2, str1);
cout<<"str1="<<str1<<endl;
cout<<"str2="<<str2<<endl;
int i=0;
while(str1[i]!='\0')
{
cout<<(int)str1[i]<<" ";
str2[i]=(char)((int)str1[i]+2);
i++;
}
cout<<endl;
i=0;
while(str2[i]!='\0')
{
cout<<(int)str2[i]<<" ";
i++;
}
cout<<endl;
cout<<str2<<endl;
i=0;
while(str2[i]!='\0')
{
cout<<(char)((int)str2[i]-2);
i++;
}
cout<<endl;
}
Is This Answer Correct ? | 14 Yes | 32 No |
Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent
In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]
Why is this loop always executing once?
How the processor registers can be used in C ?
How do I swap bytes?
Write a program to check palindrome number in c programming?
What 'lex' does?
what is purpose of fflush(stdin) function
What are reserved words with a programming language?
Please write the area of a RIGHT ANGLED TRIANGLE.
Without Computer networks, Computers will be half the use. Comment.
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.