#include<iostream>
#include<string>
using namespace std;
void display(char c[])
{
for(int i=0;c[i]!='\0';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;
for(int k=j-1;k>=0;k--)
{
cout<<temp[k];
}
cout<<endl;
}
}
int main()
{
char c[100];
cout<<"Enter Your String: ";
cin.getline(c,100);
display(c);
return 0;
}
#include<string>
using namespace std;
void display(char c[])
{
for(int i=0;c[i]!='\0';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;
for(int k=j-1;k>=0;k--)
{
cout<<temp[k];
}
cout<<endl;
}
}
int main()
{
char c[100];
cout<<"Enter Your String: ";
cin.getline(c,100);
display(c);
return 0;
}
No comments:
Post a Comment