موقع طلبة جامعة البحرين

يمكنك تصفح الموقع كزائر ولكن ندعوك لتسجيل عضوية خاصة بك لتحصل على كافة الصلاحيات مثل تنزيل ملفات المكتبة وقراءة تعليقات هيئة التدريس وغيرها. يمكنك الحصول على عضوية مجانية بالضغط على زر تسجيل. إذا قمت بالتسجيل مسبقا فيمكنك الضغط على زر دخول.

تسجيل دخول
  • قسم المكتبة الجامعية مغلق مؤقتا بعد الاستهداف التي تعرضت له بعض خدمات أمازون في البحرين، جاري استرجاع الملفات ونقلها إلى سيرفرات جديدة وسيتم بعدها اعادة افتتاح المكتبة

ITCS103 -CSC103-ITCS111-ITCS101 للدراسة و المناقشة الجماعيه 2014-2015

ما هو رأيك في الحصة و بشكل عام ( الشرح - المواضيع -الأسلوب )؟

  • سيئ ، لم أفهم شيئا .

    الأصوات: 9 28.1%
  • جيد ، فهمت نص و نص .

    الأصوات: 10 31.3%
  • ممتاز ، واضح و مقبول .

    الأصوات: 13 40.6%

  • مجموع المصوتين
    32
can u help me ? I try a lot but I cannot solve it

1) calculate the value of PI from the infinite series (PI = 4 - 4/3 + 4/5 - 4/7 + 4/9 -..) print a table that shows the approximate value of PI after each of the first 1000 terms of this series (display approximated value for PI with 8 digits of precision).

2) write program to calculate the following series ( sum = 1+3+5+7+...+N) , the user has to enter the value of N and N should be an odd number , if N was entered as an even number you should print a message "Wrong input", else if odd number find the sum of the series.​
 
can u help me ? I try a lot but I cannot solve it

2) write program to calculate the following series ( sum = 1+3+5+7+...+N) , the user has to enter the value of N and N should be an odd number , if N was entered as an even number you should print a message "Wrong input", else if odd number find the sum of the series.​


int
main()

{


int n;


int sum=0;


int i=1;


cout <<
"Enter an odd integer : ";

cin >> n;



if (n%2==0)

{

cout <<
"Wrong input" << endl;


return -1;

}


else


while (i<=n)

{

sum = sum+i;

i=i+2;

}

cout <<
"The sum = " << sum << endl;


 

return
0;

}


الاول م فهمت شنو المطلوب منه بالضبط بس شكله مثل الطريقة ,,
 
can u help me ? I try a lot but I cannot solve it

1) calculate the value of PI from the infinite series (PI = 4 - 4/3 + 4/5 - 4/7 + 4/9 -..) print a table that shows the approximate value of PI after each of the first 1000 terms of this series (display approximated value for PI with 8 digits of precision).

2) write program to calculate the following series ( sum = 1+3+5+7+...+N) , the user has to enter the value of N and N should be an odd number , if N was entered as an even number you should print a message "Wrong input", else if odd number find the sum of the series.

عطوكم الـ فورلوب for ؟؟
 
1) calculate the value of PI from the infinite series (PI = 4 - 4/3 + 4/5 - 4/7 + 4/9 -..) print a table that shows the approximate value of PI after each of the first 1000 terms of this series (display approximated value for PI with 8 digits of precision).


في هالسؤال نستخدم for loop احسن


في البداية لازم تعرفين الـ PI
نوعه double و يساوي 0

HTML:
double PI = 0;



اول شي عناصر الفورلوب في هالسؤال
البداية تكون 1
النهاية تكون 1000
الزيادة تكون 1 >> i++

HTML:
for (int i = 1 ; i<1000 ; i++ )


ثاني شي لازم تعرفين المطلوب في العملية

1- اذا كانت قيمة الـ i تساوي 1 نحط قيمة PI الاولى " 4 "
2- اذا كانت قيمة الـ i زوجية " even " الاشارة لازم تكون طرح " - "
3- اذا كانت قيمة الـ i فردية " odd " الاشارة لازم تكون جمع " + "



:: رقم 1 ::
تسوين اف ستيتمنت و تكتبين اذا كانت i تساوي 1 تكون قيمة PI تساوي 4

HTML:
if ( i == 1 )

PI = 4;



:: رقم 2 ::
تسوين اف ستيتمنت و تحطين معادلة الأعداد الزوجية
اذا كان العدد i زوجي لازم نطرح " - "

HTML:
else if( i % 2 == 0 ) 

PI = PI - 4/(2*i-1);



:: رقم 3 ::
تسوين اف ستيتمنت و تحطين معادلة الأعداد الفردية
اذا كان العدد i فردي لازم نجمع " - "

HTML:
else if ( i % 2 == 1)

PI = PI + 4/(2*i-1);



ملاحظة ::
في عملية الجمع + الطرح استخدمنه معادلة
PI = PI + 4/(2*i-1); أو PI = PI - 4/(2*i-1);




المقصود فيها ان القيمة الجديدة لـ PI تساوي القيمة السابقة لـ PI زائد او ناقص التغيير


مثال ::
بنسوي الفورلوب من 1 الى 5

اول شي عند i = 1

1%2 = 1
تروح حق الـ اف ستيتمنت الاولى و تغير قيمة الـ PI الى 4


i++ تصير الـ i = 2
2%2 = 0
تروح حق الـ اف ستيتمنت الثانية >> الاعداد الزوجية

HTML:
PI = PI - 4/(2*i-1);

PI = 4 - 4/(2*2-1)

PI = 4 - 4/(4-1)

PI = 4 - 4/3

الـ "4" عندنه اياها من الـ اف ستيتمنت الاولى و جمعنه عليها التغيير اللي صار





i++ تصير الـ i = 3
3%2 = 1
تروح حق الـ اف ستيتمنت الثالثة >> الاعداد الفردية

HTML:
PI = PI + 4/(2*i-1);

PI = PI + 4/(2*3-1)

PI = PI + 4/(6-1)

PI = PI + 4/5 

PI = 4 - 4/3 + 4/5

الـ "4 - 4/3 " عندنه اياها من الـ اف ستيتمنت الثانية و جمعنه عليها التغيير اللي صار
ماحطيت الناتج لان ابي احط طريقة الحل في الفورلوب



i++ تصير الـ i = 4
4%2 = 0
تروح حق الـ اف ستيتمنت الثانية >> الاعداد الزوجية

HTML:
PI = PI - 4/(2*i-1);

PI = PI - 4/(2*4-1)

PI = PI - 4/(8-1)

PI = 4 - 4/3 + 4/5 - 4/7


الـ "4 - 4/3 + 4/5 " عندنه اياها من الجزء السابق


i++ تصير الـ i = 5
5%2 = 1
تروح حق الـ اف ستيتمنت الثالثة >> الاعداد الفردية

HTML:
PI = PI + 4/(2*i-1);

PI = PI + 4/(2*5-1)

PI = PI + 4/(10-1)

PI = PI + 4/9 

PI = 4 - 4/3 + 4/5 - 4/7 + 4/9

الـ "4 - 4/3 + 4/5 - 4/7 " عندنه اياها من الجزء السابق




الفورلوب + الـ اف ستيتمنت

HTML:
int PI=0;   

 for (int i = 1 ; i<1000 ; i++ )


{ 
        
if ( i == 1 )

PI = 4;


else if( i % 2 == 0 ) 

PI = PI - 4/(2*i-1);  


else if ( i % 2 == 1)

PI = PI + 4/(2*i-1);     
         }



و في النهاية تسوين cout حق الـ PI و يكون setprecision(8)
 
Help me please :RpS_unsure:
wdjSROK.png
 

حاول فيها أخوي و حط محاولاتك لان هذا السؤال مهم و تكرر أكثر من مرة في الفاينل بطرق مختلفة طبعا بس الفكرة ثابتة
راح تستخدم فيها 2 فور لوب و قبل لا تسوي هذا الشي شوف المثال الي عاطنك أياه و لاحظ شنو يتغير إذا تغير زاد الرقم
 
حاولت و وصلت الى هني و وقفت
NCYvVpX.png
في الفور لوب الأول نسيت تحط النجمة عشان تنحط في الشكل و ما طبقت فكرة المثال أخوي بس أنظر للمثال أكثر بتعرف شنو قصدي
و الفور لوب الأول و الثاني فيهم كوندشن شوف المثال و أستنتج الكوندشن
 
في احد منكم خذ كوز 2 ؟
 
شلون تنحل
1. Blood sugar is considered normal if its rate is less than 140 and greater than 70, it is considered high its rate is greater than or equal to 140, and it is considered low its rate is less than or equal to 70.

Write a C++ program that asks the user to input the rate of blood sugar of each patient in a hospital (-1 to indicate the end of the data.) The program should calculate and print the flowing:
· The number of patients with normal blood sugar.
· The number of patients with high blood sugar.
· The number of patients with low blood sugar.
· The total number of patients entered by the user.


 
شلون تنحل
1. Blood sugar is considered normal if its rate is less than 140 and greater than 70, it is considered high its rate is greater than or equal to 140, and it is considered low its rate is less than or equal to 70.

Write a C++ program that asks the user to input the rate of blood sugar of each patient in a hospital (-1 to indicate the end of the data.) The program should calculate and print the flowing:
· The number of patients with normal blood sugar.
· The number of patients with high blood sugar.
· The number of patients with low blood sugar.
· The total number of patients entered by the user.



سهل أخوي هذا البرنامج عبارة عن وايل لوب بالإضافة الى 4 أف ستيتمنت
أول شي بتسويه بتسوي وايل لوب أن أذا أدخل رقم أقل من الصفر يوقف اللوب
ثاني شي تسوي شروط 4 حسب المطلوبة في السوال كلش سهل السؤال أخوي حاول فيه أخوي إذا ما عرفت حط محاولتك و بعدلها لك إنشاء الله
 
سهل أخوي هذا البرنامج عبارة عن وايل لوب بالإضافة الى 4 أف ستيتمنت أول شي بتسويه بتسوي وايل لوب أن أذا أدخل رقم أقل من الصفر يوقف اللوب ثاني شي تسوي شروط 4 حسب المطلوبة في السوال كلش سهل السؤال أخوي حاول فيه أخوي إذا ما عرفت حط محاولتك و بعدلها لك إنشاء الله
هذا حلي



#include <iostream>
using namespace std;
int main()
{
int rats,Blood,c1,c2,c3 ;
cout<<"enter rats";
cin>>rats;
while ( rats > -1)
{ if ( rats <140 && rats >70 ) c1++;
else
if ( rats >= 140 )c2++;
else
if (rats <=70 )c3++;
cout<<"enter rats";
} cin>>rats;
cout<<" • The number of patients with normal blood sugar "<<endl;
cout<<" • The number of patients with high blood sugar "<<endl;
cout<<" • The number of patients with low blood sugar "<<endl;
cout<<" • The total number of patients entered by the user "<<endl;






system("pause");
return 0;
}






 
كود:
#include <iostream>
using namespace std;
int main()
{
int rats , Blood, [B]c1=0, c2=0, c3=0 , pn=0[/B] ;
cout<<"enter rates =";
cin>>rats;
while ([B] rats != -1[/B])
{ if ( rats <140 && rats >70 ) [B]{c1++;}[/B]
else
if ( rats >= 140 )[B]{c2++;}[/B]
else
if (rats <=70 )[B]{c3++;}[/B]
[B]++pn;[/B]
cout<<"enter rates =";
[B]cin>>rats;[/B] } 
cout <<"The number of patients with normal blood sugar ="<<[B] c1 [/B]<<endl;
cout <<"The number of patients with high blood sugar ="<<[B] c2[/B] << endl;
cout <<"The number of patients with low blood sugar ="<< [B]c3 [/B]<<endl;
cout <<"The total number of patients entered by the user ="<<[B] pn[/B] <<endl;


system("pause");
return 0;
}

الأشياء إللي غيرتها خليت عليها بولد ..
1. الكاونتر لازم تخليه يساوي صفر .
2. الشرط أن اللوب تواصل إذا ما دخلنا رقم -1 ، يعني إذا كتبنا -1 توقف .
3. علشان لا يختلط شرط اللوب وشرط الإف > إللي بعد شرط الإف خله في قوسين .
4. ضفت متغير يحسب number of patients علشان في النهاية يسوي له برنت .
5. ال cin ما يصير تخليها برى اللوب لأنه إذا كانت برى ما بيرد يقرأ في اللوب بيواصل البرنامج .
6. الكاونترات إللي حطيتهم في الإف ستيتمنت لازم تطبعهم في البرنت آخر شي .
 

المرفقات

  • if.webp
    if.webp
    11.8 KB · المشاهدات: 44
ماعلييكم امر بس أحد يتأكد ليي من الحل لان البرنامج ما يشتغل عندي :mellow:
Write a C++ program with a function named "swap_floats" that takes two floating point arguments and interchanges the
values that are stored in those arguments. The function should return no value. To take an example, if the following code fragment is executed

float x = 5.8, y = 0.9;
swap_floats (x, y);
cout << x << " " << y << endl;

then the output will be
0.9 5.8

void swap_floats (float & a, float & b)
{
float temp = a;
a = b;
b = temp;
}
#inclued<iostream>
void swap_floats (float & a, float & b) ;
using namespace std;
int main ()
{
float x = 5.8, y = 0.9;
swap_floats (x, y);
cout << x << " " << y << endl;
return 0;
}​
 
void swap_floats (float & a, float & b)
{
float temp = a;
a = b;
b = temp;
}
#inclued<iostream>
void swap_floats (float & a, float & b) ;
using namespace std;
int main ()
{
float x = 5.8, y = 0.9;
swap_floats (x, y);
cout << x << " " << y << endl;
return 0;
}

الحل صح
يشتغل البرنامج >>> كلمة include يبيلها تعديل
:nosweat:


موقع ++c اونلاين
https://ideone.com/


اول مربع تحطون فيه الكود
ثاني مربع تكتبون فيه الـ بيانات اللي تبون تدخلونهم على البرنامج
و اخر شي Run
 
أهلا بالإخوان الأعزاء، في البداية أحب أتوجه بالشكر للأخ m.g.s على جهده المشكور في الإجابة على الأسئلة. دعواتي لك بالتوفيق.

ثانياً حبيت أقدم لكم حل أسئلة
Tutorial 6&7
..
الأسئلة الكتابية جميعها تم حلها فيما عدا السؤال الأول و جميع أسئلة الـ Output
بالنسبة للسؤال الأول فالجواب سيكون إما باستخدام Array أو جعل الـ Function تستقبل 4 Parameters ..

>>رابط التنزيل<<

-الرابط قد يتم مسحه بعد 90 يوماً من تاريخ الطرح.
- سيتم رفع الملف على مكتبة المنتدى بعد إضافة السؤال الأول.

-أخوكم: أحمد.
 
  • Like
التفاعلات: m.g.s
Write a program that lets the user perform arithmetic operations on two numbers. Your program must be menu driven, allowing the user to select the operation (+, -, *, or /) and input the numbers. Furthermore, your program must consist of following functions:

1. Function showChoice: This function shows the options to the user and explains how to enter data.
2. Function getData: This function reads and returns two numbers.
3. Function add: This function accepts two number as arguments and returns sum.
4. Function subtract: This function accepts two number as arguments and returns their difference.
5. Function multiply: This function accepts two number as arguments and returns product.
6. Function divide: This function accepts two number as arguments and returns quotient.



 
Write a program that lets the user perform arithmetic operations on two numbers. Your program must be menu driven, allowing the user to select the operation (+, -, *, or /) and input the numbers. Furthermore, your program must consist of following functions:

1. Function showChoice: This function shows the options to the user and explains how to enter data.
2. Function getData: This function reads and returns two numbers.
3. Function add: This function accepts two number as arguments and returns sum.
4. Function subtract: This function accepts two number as arguments and returns their difference.
5. Function multiply: This function accepts two number as arguments and returns product.
6. Function divide: This function accepts two number as arguments and returns quotient.


#include <iostream>
Using namespace std;

void showChoices();
float add(float, float);
float subtract(float, float);
float multiply(float, float);
float divide(float, float);

int main()
{
float x, y;
int choice;
do
{
showChoices();
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Sum " << add(x,y) <<endl;
break;
case 2:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Difference " << subtract(x,y) <<endl;
break;
case 3:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Product " << multiply(x,y) <<endl;
break;
case 4:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Quotient " << divide(x,y) <<endl;
break;
case 5:
break;
default:
cout << "Invalid input" << endl;
}
}while (choice != 5);

return 0;
}

void showChoices()
{
cout << "MENU" << endl;
cout << "1: Add " << endl;
cout << "2: Subtract" << endl;
cout << "3: Multiply " << endl;
cout << "4: Divide " << endl;
cout << "5: Exit " << endl;
cout << "Enter your choice :";
}

float add(float a, float b)
{
return a+b;
}

float subtract(float a, float b)
{
return a-b;
}

float multiply(float a, float b)
{
return a*b;
}

float divide(float a, float b)
{
return a/b;
}

can someone tell me if is it correct or not ?
 
عودة
أعلى أسفل