علم البيانات مستوى ثاني | جامعة صنعاء – Telegram
علم البيانات مستوى ثاني | جامعة صنعاء
1.25K subscribers
369 photos
13 videos
820 files
399 links
"قناة علمية متخصصة في مجال علم البيانات. نقدم لك محتوى علمي موثوق به، وشروحات مفصلة، وأمثلة عملية تغطي أحدث التطورات في مجال علم البيانات . هدفنا هو تمكينك من بناء قاعدة علمية قوية ومهارات عملية تساهم في نجاحك الأكاديمي والمهني."
النقاشات: @Computer_DS1
Download Telegram
علم البيانات مستوى ثاني | جامعة صنعاء
Photo
السؤال رقم 12 : خاطئ
12) what will be the output of the following?

int n=4, product=1;
for (int i=1; i<=n; ++i)
{
product *= (i+2);
}
cout << "Product of (i+2) for i from 1 to " << n << " is: " << product << endl;

A) Product of (i+2) for i from 1 to 4 is: 120
B) Product of (i+2) for i from 1 to 4 is: 60
C) Product of (i+2) for i from 1 to 4 is: 48
D) Product of (i+2) for i from 1 to 4 is: 24
الحل(الشرح) :
The for loop will now iterate from i=1 to i=4. In each iteration, product is multiplied by (i+2). So the calculations will be:
when i =1 :
* product = 1 * (1+2) = 3
when i =2 :
* product = 3 * (2+2) = 12
when i =3 :
* product = 12 * (3+2) = 60
when i =4 :
* product = 60 * (4+2) = 360
Therefore, the final value of product will be 360, which is the correct answer.
- نلاحظ ان القيمة الأخيرة للمتغير product تساوي 360
وهذه القيمة ليست ضمن الخيارات.

تصحيح الخطأ في الكود:
في كل تكرار نضرب قيمة المتغير product بـ (i +1) فتصبح :
product*= i+1
السؤال بعد التصحيح:
12) what will be the output of the following?

int n=4, product=1;
for (int i=1; i<=n; ++i)
{
product *= (i+1);
}
cout << "Product of (i+1) for i from 1 to " << n << " is: " << product << endl;

A) Product of (i+1) for i from 1 to 4 is: 120
B) Product of (i+1) for i from 1 to 4 is: 60
C) Product of (i+1) for i from 1 to 4 is: 48
D) Product of (i+1) for i from 1 to 4 is: 24
الحل(الشرح) :
The for loop will now iterate from i=1 to i=4. In each iteration, product is multiplied by (i+1). So the calculations will be:
when i =1 :
* product = 1 * (1+1) = 2
when i =2 :
* product = 2 * (2+1) = 6
when i =3 :
* product = 6 * (3+1) = 24
when i =4 :
* product = 24 * (4+1) = 120
Therefore, the final value of product will be 120, which is the correct answer.
👍2
واخييييرا

نزل موقع تقييم الدكاتره والمعيدين الذي درسونا

ادخل وقيمهم 😇


للدخول للرابط اضغط هنا
اسم المستخدم : رقم القيد
كلمة المرور : Fcit_123

واتبع التعليمات

#DS
#كلية_الحاسوب