عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 30-12-2010, 08:29 AM   #996

Mr.Ahmad

عضو هيئة تدريس

الصورة الرمزية Mr.Ahmad

 
تاريخ التسجيل: Jul 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: IT
نوع الدراسة: عضو هيئة تدريس
المستوى: متخرج
البلد: جــــدة
الجنس: ذكر
المشاركات: 2,477
افتراضي رد: [cpcs 202 - برمجة 1] لديك سؤال , شيء غير مفهوم ,,, تفضل هنا , موضوع مفيد

المشاركة الأصلية كتبت بواسطة dldoll مشاهدة المشاركة
السلام عليكم

الرجاء مساعدتي في حل هذا البرنامج
عجزت وأنا احاول


}Write “operations” function , which receive 2 numbers and character , apply the operation on the numbers, then return the result.
}
}In the main program read 2 numbers and a character , call the function and send the parameters to it, receive the result and print it on the screen.
}Note:(before call the function ,make sure the symbols will you send to the it is one of (+,-,*,/ ) and the second number is non zero if the operation ‘’/’)
كود PHP:
#include<stdio.h>
#include<conio.h>
//#include<math.h>
double Operations (double xdouble ychar op)
{
 switch (
op)
 {
 case 
'+':
  return 
y;
 case 
'-':
  return 
y;
 case 
'*':
  return 
y;
 case 
'/':
  if (
== 0
  { 
   
printf("Can not divide by zero !\n");
   break;
  }
  return 
y;
 }
 return 
0;
}
int main ()
{
 
double xy;
 
char op;
 
printf("Enter The Operations (Ex. 1 + 2) :\n");
 
scanf("%lf %c %lf",&x,&op,&y);
 
printf("= %lf\n"Operations(x,y,op));
 
getch();
 return 
0;

 

توقيع Mr.Ahmad  

 

سبحان الله وبحمد ,,, سبحان الله العظيم
الحمد لله كما ينبغي لجلال وجهه وعظيم سلطانه .
اللهم صل على محمد وعلى آل محمد كما صليت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد . اللهم بارك على محمد وعلى آل محمد كما باركت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد.

 

Mr.Ahmad غير متواجد حالياً   رد مع اقتباس