اقتباس:
|
المشاركة الأصلية كتبت بواسطة اماني1231
البرمجة الكائنية بلغة السي بلس بلس .. برنامج يحسب العلاقة x مرفوع للقوى n و ذلك من خلال استخدام النداء الذاتي
انا حاولت في البرنامج لكن ما بعرف وين الغلط
كود:
#include <iostream.h>
#include <conio.h>
#include <math.h>
int y;
int power(x,n)
{
if (n<=0 && x<=0)
return 1;
else
return ( y =power(x,n));
}
void main()
{
int y,n,x;
cout<<"\n enter number ";
cin>>x;
cout<<"\n enter the power ";
cin>>n;
cout<<"the result is "<<y<<power(y);
getch();
}
|
صباح الخير
الظاهر امس كنت نعسان شويه

الخطاء كتابي فقط واعتقد انك انتبهتي له
الرجاء المحاوله مره اخري
كود:
#include <iostream.h>
#include <conio.h>
#include <math.h>
int y;
int powers(x,n)
{
if (n<=0 && x<=0)
return 1;
else
return ( y =power(x,n));
}
void main()
{
int y,n,x;
cout<<"\n enter number ";
cin>>x;
cout<<"\n enter the power ";
cin>>n;
cout<<"the result is "<<y<<powers(x,n);
getch();
}
اشكرك علي المشاركة واتمنا لك التوفيق