30-12-2010, 08:29 AM
|
#996
|
تاريخ التسجيل: Jul 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: IT
نوع الدراسة: عضو هيئة تدريس
المستوى: متخرج
البلد: جــــدة
الجنس: ذكر
المشاركات: 2,477
|
رد: [cpcs 202 - برمجة 1] لديك سؤال , شيء غير مفهوم ,,, تفضل هنا , موضوع مفيد
السلام عليكم
الرجاء مساعدتي في حل هذا البرنامج
عجزت وأنا احاول
}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 x, double y, char op) { switch (op) { case '+': return x + y; case '-': return x - y; case '*': return x * y; case '/': if (y == 0) { printf("Can not divide by zero !\n"); break; } return x / y; } return 0; } int main () { double x, y; 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; }
|
|
سبحان الله وبحمد ,,, سبحان الله العظيم الحمد لله كما ينبغي لجلال وجهه وعظيم سلطانه . اللهم صل على محمد وعلى آل محمد كما صليت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد . اللهم بارك على محمد وعلى آل محمد كما باركت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد.
|
|
|
|