تطبيق الامثله السابقه على function الفنكشن

امثله على ال function


مثال علامات 10 طلاب ..الخ 




 #include <iostream>
#include <string>
using namespace std ;
float min1(float x1,float x2,float x3,float x4,float x5,float x6,float x7,float x8,float x9,float x10){
float min;
min=x1;
if (min>x2) min=x2;
 if (min>x3) min=x3;
 if (min>x4) min=x4;
 if (min>x5) min=x5;
if (min>x6) min=x6;
if (min>x7) min=x7;
if (min>x8) min=x8;
if (min>x9) min=x9;
if (min>x10) min=x10;
return min ;
}

float max1(float x1,float x2,float x3,float x4,float x5,float x6,float x7,float x8,float x9,float x10){
 float max=x1;
if (max<x2)  max=x2;
 if (max<x3)  max=x3;
   if (max<x4)  max=x4;
   if (max<x5)  max=x5;
if (max<x6)  max=x6;
 if (max<x7)  max=x7;
 if (max<x8)  max=x8;
   if (max<x9)  max=x9;
if (max<x10)  max=x10;
}
void main ()
{
 for(int i=0;i<10;i++)
{string name ;
float x1,x2,x3,x4,x5,x6,x7,x8,x9,x10   , avg  , min ,max ;
cout<<"name ::  ";
cin>> name;
cout<<"10 mark:\n";
cin>>x1>>x2>>x3>>x4>>x5>>x6>>x7>>x8>>x9>>x10;
avg=(x1+x2+x3+x4+x5+x6+x7+x8+x9+x10)/10;
        min =min1(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 );
max=max1(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 );



cout<<"avg="<<avg<<" \n min="<<min<<"\n max= "<<max<<endl;
if (avg>=50) cout<<"pass"<<endl;
else  cout<<"F"<<endl;
} system("pause");
 }



مثال حساب راتب الموظف ..الخ:


 #include <iostream>
#include <string>
using namespace std ;void print1(string name ,float work_hours_in_month,float salary ,float tax,float after_tax ){
cout<<"\n*****************************\n";
cout<<"Employee Name:"<<name <<endl;
cout<<"Number of working hours this month:"<<work_hours_in_month <<endl;
cout<<"Timepiece price: $ 20" <<endl;
cout<<"Total salary:"<<salary <<endl;
cout<<"Amount of tax deduction:"<<tax <<endl;
 cout<<"net salary:"<<after_tax <<endl;
cout<<"\n*****************************\n";
}void inpo(string  &name,  float  &work_hours ){
cout<<"enter the name: \t";
cin >> name;cout<<" \n enter the work hours:\t";
cin >> work_hours;
}float w (float work_hours){  return work_hours*22;

}

void main (){ 
string name ;

float work_hours,work_hours_in_month,   salary,       tax,     after_tax ;

inpo (name,work_hours);



work_hours_in_month = w(work_hours);


salary=work_hours_in_month * 20 ; 
tax = salary * 0.06;after_tax =salary-tax;

print1(name , work_hours_in_month, salary , tax, after_tax);



 system("pause"); 

 }






مثال تبديل القيم في المتغيرات ..الخ:



 #include <iostream>#include <string>
using namespace std ;void fun (int &a, int &y){int t;t=a; a=y; y=t; 
cout<<"x="<<a<<"y="<<y<<endl;
}
void main ()
{ int x=50,y=10; 
 cout<<"x="<<x<<"y="<<y<<endl;  fun (x,y);
 cout<<"x="<<x<<"y="<<y<<endl; system("pause");  }




رابط الامثله قبل تطبيقها على الفنكشن :

http://abdelrhmanmt1.blogspot.com/2017/05/include-using-namespace-std-void-main.html


Comments

Popular posts from this blog

الدرس التاسع 9: الفنكشن function تعريفه وانواعه

الدرس السابع 7: جمله الشرط Switch في لغه c++

الدرس الثالث عشر 13: القيمه العشوائيه rund في c++