I am looking for a C++ program that would allow me to display the ASCII code of a word or phrase itself. Can any one help me?
Printable View
I am looking for a C++ program that would allow me to display the ASCII code of a word or phrase itself. Can any one help me?
Basically the letters "A" to "Z" has the value of 65 to 90 while the letters "a" to "z" has the value of 97 to 122 in ASCII code. Try the C++ program based on this on your own.
Thank you for your response.
I have made the basic model of the program based on your guidance, but again got the problem.
So the program that I started works as planned, but only for a word and not for a full sentence.
Here is the program:
Code:#include <iostream>
#include <cstring>
using namespace std;
int i, length, JC;
string clear; / / Declaration of clear chain
int main ()
{
cout << "Enter the clear text:";
cin >> clear; // Entering the clear chain
length = clear.length(); // Set the length of chain length
cout << endl;
cout << length << endl; // Display the length of the string
cout << endl;
for (i = 0; i < length; i++)
{
JC = int (clear[i]) + int (3);
if ((JC >= 90 && JC < 97) || (JC > 122))
{
JC = JC - 26;
}
cout << char (JC);
}
cout << endl;
system ("pause");
return (0);
}