menu bar

Wednesday, 14 September 2016

Parameter Nilai

struktur data
latihan minggu 1

Parameter Nilai

program 1.1

#include <iostream>

using namespace std;

int Abc(int a, int b, int c)
{
return a+b+b*c+(a+b-c)/(a+b)+4;
}

main()
{
cout<<Abc(2,3,4)<<endl;
}

output


------------------------------------------------------------------------------------------------------------

Fungsi Template

program 1.2

#include <iostream>

using namespace std;

float Abc(float a, float b, float c)
{
return a+b+b*c+(a+b-c)/(a+b)+4;
 } 
 main()
 {
  cout<<Abc(2,3,4)<<endl;
 }

output



program 1.3

#include <iostream>

using namespace std;

template<class T>
T Abc(T a, T b, T c)
{
return a+b+b*c+(a+b-c)/(a+b)+4;
}
main()
{
cout<<Abc(2,3,4)<<endl;
}

output


------------------------------------------------------------------------------------------------------------

Reference Parameter

program 1.4

#include <iostream>

using namespace std;

template<class T>
T Abc(T&a, T&b, T&c)
{
return a+b+b*c+(a+b-c)/(a+b)+4;
}
main()
{
int  a=2,b=3, c=4;
cout<<Abc(a,b,c)<<endl;
}

output


------------------------------------------------------------------------------------------------------------

Reference Parameter

program 1.5

#include <iostream>

using namespace std;

template<class T>
T Abc(const T&a,const T&b,const T&c)
{
return a+b+b*c+(a+b-c)/(a+b)+4;
}
main()
{

cout<<Abc(2,3,4)<<endl;
}

output



program 1.6

#include <iostream>

using namespace std;

template<class Ta, class Tb, class Tc>
Ta Abc(const Ta&a,const Tb&b,const Tc&c)
{
return a+b+b*c+(a+b-c)/(a+b)+4;
}
main()
{

cout<<Abc(2,3,4)<<endl;
}

output


------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------

ini punya temen:
            ==> Raka Primayuda
            ==> Irpan



No comments:

Post a Comment