Sunday 24 June 2012

c++ program that accept string(chacters) input and convert it into a bianry and display it's binary.

#include<iostream>
#include<string>
using namespace std;
int main()
{
    char c[100];
    cout<<"Enter Your String: ";
    cin.getline(c,100);

    for(int i=0;c[i]!='\0';i++)
    {



char ch=c[i];
    int j=0;
    int temp[15];
        while(c[i]>0)
            {
                    temp[j]=c[i]%2;
                    c[i]=c[i]/2;
                    j=j+1;
            }
        cout<<endl;
    cout<<ch<<" :";
        for(int k=j-1;k>=0;k--)
               cout<<temp[k];
        cout<<endl;
    }
    return 0;
}


YOU CAN ALSO REFERS FOLLOWING PROGRAMS:

No comments:

Post a Comment