18-03-2010, 12:22 AM
|
#3
|
تاريخ التسجيل: Jul 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: IT
نوع الدراسة: عضو هيئة تدريس
المستوى: متخرج
البلد: جــــدة
الجنس: ذكر
المشاركات: 2,477
|
رد: كم سوال يحتاجو لجواب
Q3: Write and run a program that read’s user’s age and then prints:
“You are a child” if the age < 18
“You are adult” if 18 ? age< 65
“You are a senior citizen” if age ? 65
كود PHP:
#include <iostream> #include <conio.h> int main () { int age; cout << "Please Enter Your Age : "; cin >> age; if (age < 18) cout << "You are a child" <<endl; else if (age < 65) cout << "You are adult" <<endl; else cout << "You are a senior citizen" <<endl; return 0; }
Q4: Write a C++ program to calculate the square root of a user-entered number.
Hint: Before calculating the square root, you should validate that the number is not
negative.
كود PHP:
#include <iostream> #include <conio.h> #include <math.h> int main () { double num; cout << "Please Enter Number : "; cin >> num; if (num >= 0) cout << "Square Root of " << num << " Equal " << sqrt(num) << endl; else cout << "Number is not negative" << endl; return 0; }
لا تنسخ ,, بل تعلم وحاول , وإن باتت محاولاتك بالفشل إنظر إلى الحل . لكي تتعلم .
|
|
|
|
سبحان الله وبحمد ,,, سبحان الله العظيم الحمد لله كما ينبغي لجلال وجهه وعظيم سلطانه . اللهم صل على محمد وعلى آل محمد كما صليت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد . اللهم بارك على محمد وعلى آل محمد كما باركت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد.
|
|
|
|