C++ انشئ برنامج الة حاسبة باستخدام الدوال :

  • برمجة سي بلس بلس

برنامج الة حاسبة باستخدام الدوال C++ ? 

الأجوبة

#include <iostream.h>
// functions initialize
int Pluse ( int, int );
int Minus ( int, int );
int Div ( int, int );
int Mult ( int, int );
void main ( )
{
 // first and second integer number
 int Fir_Num;
 int Sec_Num;
 // kind of operation
 char Ope;
 // input phase
 cout << "Enter the first number : ";
 cin >> Fir_Num;
 cout << "Enter the second number : ";
 cin >> Sec_Num;
 cout << "Enter ur operation : ";
 cin >> Ope;
 // switch body
 switch (Ope)
 {
 // if operation is pluse
 case ' + ' :
 cout << "The result is : ";
break;
 // if operation is minus
 case ' - ' :
 cout << "The result is : "
 << Minus ( Fir_Num, Sec_Num );
 break;
 // if operation is mult
 case '*' :
 cout << "The result is : "
 << Mult ( Fir_Num, Sec_Num );
 break;
 // if operation is divison
 case ' / ' :
 cout << "The result is : "
 << Div ( Fir_Num , Sec_Num );
 break ;
 // if operation is not logical
 default :
 cout << "Sorry ur operation is wrong ";
} // end switch
} // end main
// pluse function body
int Pluse ( int x, int y )
{
 return x + y ;
}
// minus function body
int Minus ( int x, int y )
{
 return x - y;
}
// div function body
int Div ( int x, int y )
{
 if ( y == 0 )
 {
 cout << "Error division by zero ";
 return 0;
 }
 else
 return x / y;
}
// mult function body
int Mult ( int x, int y )
{
 return x * y ;
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...