بابهت: دروست کردنی بەرنامەی گورینی ژمارەی Decimal بۆ Binary بە C++
بەرێزان هەروەک دەزانن کە کۆمپیوتەر لەسەر سیستەمی دوانی کار دەکات واتا(0،1)، بویە من دەمەوێت لێرەدا بەرنامەیەک دروست بکەم بۆ گۆرینی ژمارەیەکی دەیی(Decimal) بۆ ژمارەی دوانی(Binary).
#include<iostream.h>
void main()
{
int b[16],d,i=0,x;
cout<<"\t\t\"Converting Decimal to Binary\"\n\n"
<<"\nEnter a decimal number to convert it into binary number:";
cin>>d;
x=d;
if (d>=0)
{
while(d>0)
{
b[i]=d%2;
d=d/2;
i++;
}
cout<<endl
<<x
<<" in decimal = ";
if(x!=0)
{
for(int j=i-1; j>=0; j--)
cout<<b[j];
cout<<" in binary";
}
else
cout<<" 0 in binary";
}
else
cout<<"\n\nWrong input.";
}
[/center]