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

أرجو من الأخ Smart Dev الدخول عااااااااجل::::

مغلق
بدأه الحاير في 9 مايو 2003 · 2 رد · 517 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

(clock)

السلام عليكم ورحمة الله::::

بغيت ياخيي منك طلب وأرجو أن لاتردني فيه ....

وهو أن تضع لي الصيغة لهذا السؤال (مرة أخرى) باستخدام scanf

أرجو أن لا تخذلوني في حله وهو برنامج آلة حاسبة ولكن باستخدام

الـ(switch) والـ(do… while)

والـ(:case) والـ(break) والـ(default) والـ(getch())

---------------------------

والبرنامج كالتالي:

#include

main()

{

float nm1,nm2,result;

char op;

do{

printf("Enter the first number:n");

scanf("%f",&nm1);

printf("Enter the second number:n");

scanf("%f",&nm2);

printf("Enter the operation:n");

scanf("%c",&op);

switch(op)

{

case'+':

{

result=nm1+nm2;

printf("the result of nm1+nm2=%f",result);

break;

}

case'-':

{

result=nm1-nm2;

printf("the result of nm1-nm2=%f",result);

break;

}

case'*':

{

result=nm1*nm2;

printf("the result of nm1*nm2=%f",result);

break;

}

case'/':

{

result=nm1/nm2;

printf("the result of nm1/nm2=%f",result);

break;

}

default :

printf("you enter unknown operator:n");

printf("nAgain: (y/n)") ;

break;

}

}while((ch==getch()=='y'));

return(0);

}

&&&&&&&&&&&&&&&&&&&&&&&&&&&&

أرجو التجاوب من الجميع وأرجو إظهار الخطأ والسرعة في الرد وشكراً

لكم مرةً أخرى ,,,

لأن الدكتور عطانا السؤال كما وضعت وأنا قريب أجن ماني عارف كيف بـاستخدام scanf وأرجو أن لا أزعجك وأرجو أيضاً من اسماعيل عنبجيري الدخول وآسف إن كان اسمك وضعته خطأ

وأيضاً هاني الأتاسي وغيرهم من المشرفين شاكراً لكم حسن مشاكاتكم و زيارتكم ...

مع تحياتي لكم جميعاً خاصة ولأعضاء المنتدى عامة,,,

#2

بسم الله الرحمن الرحيم

Reading data from the keyboard with scanf 





Used to assign a value typed on the keyboard to a variable.



Used similarly to printf.  You must use the following conversion specifications: 





Data Type printf converstion spec. scanf conversion spec.



int   %d    %d



long   %ld    %ld



float  %f    %f



double  %f    %lf



char  %c    %c



character string %s    %s 





The user must type a value followed by the Enter Key

.

#include
#include // to call getche()
main()
{
float nm1,nm2, result;
char ch;
char c;
do{
printf("nEnter your operation directly(for example: 2 + 3):n" );
scanf("%f %c %f", &nm1, &c, &nm2);
switch©
{
case '+':
{
result=nm1+nm2;
printf("nthe result of nm1+nm2= %f",result);
break;
}
case '-':
{
result=nm1-nm2;
printf("nthe result of nm1-nm2=n%f",result);
break;
}
case '*':
{
result=nm1*nm2;
printf("nthe result of nm1*nm2= %f",result);
break;
}
case '/':
{
if (nm2 == 0.0)
 //you can't devide by zero
break;
result=nm1/nm2;
printf("nthe result of nm1/nm2= %f",result);
break;
}
default :
printf("nyou enter unknown operator:n");
break;
}
printf("nAgain: (y/n)");
}while( ( ch=getche() ) == 'y' );
return(0);
}
#3

السلام عليكم ,,,,,,

ياأخي يا smart dev لقد نسيت استعمال الأوامر printf و scanf لأني أريد أن أطلب من المستخدم أن يدخل ماهو مطلوب (أي أريده كما أنزلته ولكن مع الترتيب الصحيح) وآسف إن كنت أزعجتك شاكراً لك الرد::::

أخوك الحــــــــــــــــايــــــــــر:::

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

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…