علم البيانات مستوى ثاني | جامعة صنعاء
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.
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
exam 7 with out answer .pdf
260.1 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
exam 6 sunday late withoutanswer - Copy.pdf
220.9 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
exam 4 with answer -out .pdf
247.9 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
exam 2 without answer monday .pdf
262.7 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
exam3 with out answer - .pdf
285.4 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
exam 56 sunday morniing with outanswer .pdf
146.5 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
exam 9 with out wed.pdf
213.2 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
exam 8 wihout answer .pdf
246.6 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
exam 7 with out answer .pdf
260.1 KB
نماذج نصفية أساسيات برمجة للدكتورة مروة الهادي
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
#نماذج
#نماذج_نصفية
#مروة_الهادي #أساسيات_البرمجة
#programming_fundamentals
⭕واخييييرا
نزل موقع تقييم الدكاتره والمعيدين الذي درسونا
ادخل وقيمهم 😇
واتبع التعليمات
#DS
#كلية_الحاسوب
نزل موقع تقييم الدكاتره والمعيدين الذي درسونا
للدخول للرابط اضغط هنا
اسم المستخدم : رقم القيد
كلمة المرور :Fcit_123
واتبع التعليمات
#DS
#كلية_الحاسوب