الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

convert biary to>>>>وين الخطأ

مغلق
بدأه vb man في 5 أبريل 2003 · 3 رد · 522 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

سلام عليكم...

أرجو ممن لديه معرفه أن يساعدني....

أنا حاولت اكتب برنامج يحول العدد للأساس 2 (الباينري) إلى العدد للأساس 10(الدسيمال)...

أرجو مساعدتكم



#include<math.h>



main()

{

int x[100],count2,count=0,i=0;

int decimal=0;



printf("enter a binary number:");

while((x=getchar())!='n')

{

++count;

++i;

}

count2=count;

for (i=0;i<=count2;count2--)

{

(x-'0')*=pow(2,count2);

decimal+=(x-'0');

i++;

}

printf("n the decimal=%d",decimal);

}
#include<stdio.h>

#2

قم باستخدام التالي :

#include<stdio.h>



main()

{

	int x[100], count = 0, i = 0;

	int decimal = 0;

	int mult2 = 1;



	printf("enter a binary number:");

	while((x[i++] = getchar()) != 'n')

	;	



	count = i - 1;



	for (i = count - 1; i >= 0; i--)

	{

  if (x = '1')

 	 decimal += mult2;

  mult2 *= 2;

	}



	printf("n the decimal=%d n",decimal);

}

Coding on the Cloud and for the Cloud!

My Blog

#3

مشكوووووور وما تقصر بس في تصحيح بسيط للبرنامج اللي كتبته

#include<stdio.h>



main()

{

	int x[100],count=0,i=0;

	int decimal=0;

	int mult2=1;



	printf("enter a binary number:");

	while((x[i++]=getchar())!='n')

	;



	count=i-1;



	for (i = count - 1; i >= 0; i--)

	{

  if (x=='1')

 	 decimal+= mult2;

  mult2*=2;

	}



	printf("n the decimal=%d n",decimal);

}
#4

:) شكرا على الانتباه ..

Coding on the Cloud and for the Cloud!

My Blog

هذا الموضوع مغلق.

مواضيع مشابهة