الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مسآعده لآ هنتم ,,

بدأه فوضوية في 9 مايو 2011 · 10 رد · 775 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلآم عليكم ورحمه آلله وبركآته ,,

انا عندي سؤآل يبغى جمع كسرين وطالب مني ثلاث فنكشن الاولى تقرآ والثانيه تجمع والثالثه تطبع

وهذي محاولتي ممكن تشيكون عليه :blush:

#include<iostream>
using namespace std;
int getNumber (void);
double add(int, int, int, int);

void displayFraction(int numerator, int denuerator);

int main()
{
double Result;
// read first fraction

// read second fraction

Result = add( numerator1 , denominator1 , numerator2 , denominator2 );
cout<<Result;
//display fraction1 + fraction2 = Result
//cout<<               << '+' <<              <<'='<< Result ;
return 0;

}


int getNumber ()
{
	int numerator1 , denominator1 , numerator2 , denominator2;

	cout<<"\nEnter the numerator : ";
	cin>>numerator1;
	cout<<"\nEnter the denominator : ";
	cin>>denominator1;
		cout<<"\nEnter the numerator2 : ";
	cin>>numerator2;
	cout<<"\nEnter the denominator2 : ";
	cin>>denominator2;

	return numerator1 , denominator1 , numerator2 , denominator2;

}

double add(int)
{
	double sum;
	sum=( numerator1/denominator1)+(numerator2/denominator2);

	return sum;
}

void displayFraction(int numerator, int denominator)
{

}
#2

السلام عليكم ورحمه الله وبركاته

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

.:: Wish to become better and better ::.

#3

قصدك كذآ يعني ؟

#include<iostream>
using namespace std;
void getNumber (void);
double add(int, int, int, int);

void displayFraction(int numerator, int denuerator);

int main()
{
double Result;
// read first fraction

// read second fraction

Result = add( numerator1 , denominator1 , numerator2 , denominator2 );
cout<<Result;
//display fraction1 + fraction2 = Result
//cout<<               << '+' <<              <<'='<< Result ;
return 0;

}


void getNumber ()
{
        int numerator1 , denominator1 , numerator2 , denominator2;

        cout<<"\nEnter the numerator : ";
        cin>>numerator1;
        cout<<"\nEnter the denominator : ";
        cin>>denominator1;
                cout<<"\nEnter the numerator2 : ";
        cin>>numerator2;
        cout<<"\nEnter the denominator2 : ";
        cin>>denominator2;


}

double add(int)
{
        double sum;
        sum=( numerator1/denominator1)+(numerator2/denominator2);

        return sum;
}

void displayFraction(int numerator, int denominator)
{
cout<<add(sum);
}
#4

السلام عليكم

هذا تصحيح الكود :

#include<iostream>
using namespace std;
void getNumber(void);
float add(int,int,int,int);
void displayFraction(float);
int numerator1 , denominator1 , numerator2 , denominator2;

int main()
{
    float Result;
    getNumber();
    Result = add( numerator1 , denominator1 , numerator2 , denominator2 );
    displayFraction(Result);
    return 0;
}

void getNumber()
{
     cout<<"Enter the numerator : ";
     cin>>numerator1;
     cout<<"Enter the denominator : ";
     cin>>denominator1;
     cout<<endl<<"Enter the numerator2 : ";
     cin>>numerator2;
     cout<<"Enter the denominator2 : ";
     cin>>denominator2;
}

float add(int x, int y,int z,int t)
{
      return ((float)x/y+ (float)z/t);
}

void displayFraction(float sum)
{
     cout<<endl<<sum<<endl;
}

هذا إيميلي للمساعدة :

khaled_prg@live.fr

بالتوفيق.

#5

ممكن تشرح لي هذي الفنكشن ابي العمليه اللي برجعها , يعني ليش قلت فلوت وانا ب الاساس لما ارجع شي ما احط آلتآيب

float add(int x, int y,int z,int t)
{
      return ((float)x/y+ (float)z/t);
}

هنآ الsum من وين جبتها !!!

void displayFraction(float sum)
{
     cout<<endl<<sum<<endl;
}
#6

شوف هنا كتبته بعد تغيير التايب لآني آبيه كذآ لكن مآضبط معي

#include<iostream>
using namespace std;
int getNumber(void);
double add(int,int,int,int);
void displayFraction(int numerator, int denuerator);
int numerator1 , denominator1 , numerator2 , denominator2;

int main()
{
    double Result;
	int fraction1 , fraction2;
    getNumber();
    Result = add(numerator1 , denominator1 , numerator2 , denominator2 );
    displayFraction( fraction1 ,fraction2);
    return 0;
}

int getNumber()
{
     cout<<"Enter the numerator : ";
     cin>>numerator1;
     cout<<"Enter the denominator : ";
     cin>>denominator1;
     cout<<endl<<"Enter the numerator2 : ";
     cin>>numerator2;
     cout<<"Enter the denominator2 : ";
     cin>>denominator2;

	 return numerator1 , denominator1 , numerator2 , denominator2;
}

double add(int numerator1, int denominator1,int numerator2,int denominator2)

{
	double fraction1=numerator1/denominator1;
		double fraction2 =numerator2/denominator2;
		//double Result= fraction1 + fraction2 ;
      return fraction1 , fraction2 ;
}

void displayFraction(int fraction1 , int fraction2 )
{
	double sum=fraction1 + fraction2 ;
     cout<<endl<<sum<<endl;
}
#7
اقتباس
يعني ليش قلت فلوت

لأن قسمة int على int ستكون int و أنا أريد الناتج بالفاصلة, عاشن كده لازم أحول الناتج إلى float (هذه العملية تُسمى بالـ casting)

سؤال يطرح نفسه .. ليش ما نكتب :

return (float)(x/y+ z/t);

اقتباس
هنآ الsum من وين جبتها !!!

جبتها من جيبي :lol:

الـ sum عبارة عن ناتج جمع الكسرين, نمرره كمعامل للدالة الأخيرة التي ستظهره.

أي سؤال .. أنا في الخدمه :)

اقتباس
return numerator1 , denominator1 , numerator2 , denominator2;

الدالة تعيد قيمة واحدة و انت قلت أنها تعيد أربع قيم !

ما فائدة إعادة القيم عند الإدخال ؟

#8

لآني آبغا آجمعهآ

الكود آللي ارسلته في الاخير فيه خطأ بسيط بس مو عارفه وشو , ممكن تسآعدني ؟

#9

السلام عليكم ورحمه الله وبركاته

اختي جربي ده


#include<iostream>
void getNumbers();
double add(float frac1, float frac2);
void displayFractiondouble sum);
int numerator1 , denominator1 , numerator2 , denominator2;
main()
{
float frac1,frac2;
double sum;
getNumbers();
frac1=numerator1/denominator1;
frac2=numerator2/denominator2;
sum=add(frac1,frac2);
displayFraction(sum);
}


void getNumbers()
{


cout<<"\nEnter the numerator : ";
cin>>numerator1;
cout<<"\nEnter the denominator : ";
cin>>denominator1;
cout<<"\nEnter the numerator2 : ";
cin>>numerator2;
cout<<"\nEnter the denominator2 : ";
cin>>denominator2;

}

double add(float fraction1,float fraction2)
{
double sum;
sum=fraction1+fraction2;
return sum;
}

void displayFraction(double sum)
{
cout<<"\nSum= "<<sum;
}

.:: Wish to become better and better ::.

#10

آخوآني الآعزآء السؤآل آللي جآيني محدد لي التآيب

#include<iostrearm>
using namespace std;
int getNumber (void);
double add(int, int, int, int);
void displayFraction(int numerator, int denuerator):

int main()
{
double Result;
// read first fraction

// read second fraction

Result = add(

//display fraction1 + fraction2 = Result
cout<<
<< ’+’ <<
return 0;

}

int getNumber ()
{
//complete
}

double add(int
{
//complete
}

void displayFraction(int numerator, int denominator
{
//complete
}

,

,

,

);

<<’=’<<

;

numerator1 ,int denominator1 ,int numerator2,int denominator2)

هذآ آلسؤآل / هو محدد آلتآيب وانا كتبت حلي نفس التايب اللي محدده بس في غلط في الجمع

#11
اقتباس
السلآم عليكم ورحمه آلله وبركآته ,,

و علیکم السلام و رحمة الله و برکاته الأخت الکریمة..

ما الذی کتب خالد فی رده الأولی صحیح، لکن ان لا تریدین طریقته فی الجمع، فهذا تغییر صغیر فی الأکواد:

#include<iostream>
using namespace std;

void getNumber(void);
float add(float,float,float,float);
void displayFraction(float);

int numerator1 , denominator1 , numerator2 , denominator2;

int main()
{
	float Result;
	getNumber();
	Result = add( numerator1 , denominator1 , numerator2 , denominator2 );
	displayFraction(Result);

	system("pause");
	return 0;
}

void getNumber()
{
 	cout<<"Enter the numerator : ";
 	cin>>numerator1;
 	cout<<"Enter the denominator : ";
 	cin>>denominator1;
 	cout<<endl<<"Enter the numerator2 : ";
 	cin>>numerator2;
 	cout<<"Enter the denominator2 : ";
 	cin>>denominator2;

}

float add(float x, float y,float z,float t)
{
  	float sum;
  	sum = (x/y) + (z/t);
  	return sum;
}

void displayFraction(float sum)
{
 	cout<<endl<<sum<<endl;
}

و ایضا فی الاکواد التی انت تکتبین فی ردودک توجد أخطاء کثیرة و اصلا لا یمکن التصحیح، علی ما یبدو تکتبین بشکل ناقص، لکن مع هذا ایضا یوجد أخطاء آخر بسبب عدم تبهر فی syntax هذه اللغة ( کمثل عدم تبهری أنا فی syntax اللغة العربیة :P ).

khaled_prg كتب:

هذا إيميلي للمساعدة :

ان ترید خیر و تبحث عن الخیر ، فاکتب هنا مساعداتک حتی یستفید عدد کثیر من الأعضاء، لا فقط شخص واحد و معین. و بارک الله فیک و یجزیک الله جزاء هذه مساعدتک.

اطیب تحیة.

تم تعديل هذه المشاركة بواسطة C77431 في 10 مايو 2011 في 14:39

2

مواضيع مشابهة