English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

Are you looking for something like this:

#include
using namespace std;
int main()
{ char alp;
int place;
cout<<"Enter a alphabet:";
cin>>alp;
int num = alp;
for (place=1;place<=num;place*=2);
for (place/=2; place>=1;place/=2)
{
cout< num=num%place;
}
cout<<"\n";
return 0;
} //main

Hope this helps!

2007-03-10 05:03:37 · answer #1 · answered by Rainmaker 2 · 0 0

You need to tell us more. Do you mean that you will read numbers represented as text from stdin, and then print the numbers in binary?

If so, I'd read the numbers using the normal method (cin, for example), and then write a function that takes an int and prints the binary representation of the number. You'll need to use bitwise operators to do this, or perhaps use an arithmetic trick. Why not look up the use of the bitwise AND operator (&). It will certainly lead to a solution.

2007-03-10 04:41:20 · answer #2 · answered by arbeit 4 · 0 0

Alphabets to binary numbers?

Usually alphabets are converted to an ASCII equivalent. E.g.: A space is ASCII 32 (0x20h)

From there you could go to hex, or binary. Are you sure you want to go to binary?

2007-03-10 04:48:27 · answer #3 · answered by T J 6 · 0 0

try using c++ code snippets in vc++ or try searching for algorythms on yahoo

2007-03-10 04:46:44 · answer #4 · answered by the_rock55_2001 3 · 0 0

fedest.com, questions and answers