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

ما الخطا في برنامجي

بدأه Mr.Raed في 2 يونيو 2011 · 1 رد · 362 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع
# include < iostream > 

using namespace std;



int square(int side)


{

int  square;

square=side*side;

return square;

}

int rectangle(int b, int c)

{

int rectangle;

rectangle=b*c;

return rectangle;

}

double circle(double t, double radius)

{

double circle;

//double t=3.14;










 circle=t*radius;


return circle;

}

int main()

{

int p;

cout<<"To know the area of the square, press 1"<<endl;

 cout<<"To know the area of a rectangle Press 2"<<endl;

cout<<"To know the area of a circle, press 3\n"<<endl;

cout<<"What do you want to calculate: "<<endl;

cin>>p;










 if (p==1)


{

int m,n,s=1;

cout<<"Enter the length of one side of the square"<<endl;

cin>>m;

n=square(s);

cout<<"the area of the square is: "<<n<<endl;

return 0;

}

else if (p==2)

{










int r,y,u=1,b,c;


cout<<"Enter the length and width of the rectangle: "<<endl;

cin>>r>>y;

u=rectangle(b,c);

cout<<"the area of the rectangle is: "<<u<<endl;

return 0;

}

else if (p==3)

 {










double l, w=1 ,t,radius;


cout<<"enter the radius of the circle: "<<endl;

cin>>l;

w=circle(t,radius);

cout<<"the area of the circle is: "<<w<<endl;

return 0;

}





}

ارجوكم اريد توضيح الاخطاء لي لان اختباري قريب
1f557e95a4.jpg
#2
اقتباس
if (p==1)

{

int m,n,s=1;

cout<<"Enter the length of one side of the square"<<endl;

cin>>m;

n=square(s);

cout<<"the area of the square is: "<<n<<endl;

return 0;

}

الخطأ في انك تمرر للداله المتغيـر s وقيمتـه = 1 ففي كل مره تطلب المساحه تجد الناتج = 1 ..

والمفترض انك تمرر للداله المتغيـر ( m ) وهو طول الضلع الذي ادخلـه المستخدم ..

جرب هذا الكود .. وحاول تعدل الباقي بنفس الطريقـه ..

if (p==1)


{

int m;

cout<<"Enter the length of one side of the square"<<endl;

cin>>m;

cout<<"the area of the square is: "<<"\t";

cout<<square(m)<<endl;

return 0;

}

اتمنى اكون افدتك

:)

تم تعديل هذه المشاركة بواسطة آمـــال في 2 يونيو 2011 في 22:48

1

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