سلام الله عليكم ورحمته وبركاتة . .
مطلوب علي مشروع آلة حاسبة بالفنكشن . .
عملت المشروع لكنه من عددين فالمطلوب ان يدخل المستخدم أكثر من عدد
مثل : 3+2+3+4..........الخ والعمليات الأخرى بنفس الشكل . .
اكوووووون شاكر لكم
وهذا الكود اللي عملته :
#include <iostream>
double add (double x , double y )
{ return x+y ; }
double sub (double e , double z )
{ return e - z ; }
double multi (double a , double b )
{
return a*b ; }
double division (double t , double f )
{ return t/f ; }
main()
{ double a , b ,c ;
cout <<"enter 1 for process ' + ' ; 2 for ' - ' ; 3 for ' * ' ; 4 for ' / ' ..."<<endl;
cin >> c ;
if (c==1)
{ cout << " now in process the add .."<<endl;
cout <<"enter first number :";
cin >> a ;
cout <<"enter second number :";
cin >> b ;
cout <<a<<"+"<< b <<"="<<add(a,b) ;
}
else if (c==2)
{ cout << " now in process the sub.. "<<endl;
cout <<"enter first number :";
cin >> a ;
cout <<"enter second number :";
cin >> b ;
cout <<a<<"-"<< b <<"="<<sub(a,b) ;
}
else if (c==3)
{ cout << " now in process the multiplication.. "<<endl;
cout <<"enter first number :";
cin >> a ;
cout <<"enter second number :";
cin >> b ;
cout <<a<<"*"<< b <<"="<<multi(a,b) ; }
else if (c==4)
{ cout << " now in process the division... "<<endl;
cout <<"enter first number :";
cin >> a ;
cout <<"enter second number :";
cin >> b ;
cout <<a<<"/"<< b <<"="<<division(a,b) ;
}
else
{ cout<<"eror";}
for (;;) ;
}