In: Computer Science
SumOfTwoHighest returns the sum of the two largest numbers
SumOfTwoHighest(1,2,3) ➔ 5
SumOfTwoHighest(0,1,0) ➔ 1
SumOfTwoHighest(-1,-2,-3) ➔ -5
int SumOfTwoHighest(int i, int j, int k)
{
}
#include <iostream>
using namespace std;
int SumOf3Digits(double d)
{
string s = to_string(d);
int sum=0;
for(int i=0;i<s.size();i++)
{
if(s[i]!='.')sum= sum+ s[i]-'0';
}
return sum;
}
int max(int i, int j)
{
return i>j? i:j;
}
int Power(double d, int pow = 2)
{
if(pow == 0)
return 1;
if(pow == 1)
return d;
if(pow == 2)
return d*d;
return d*d*d;
}
nt main() {
cout<<SumOf3Digits(5.13)<<endl;
cout<<max(5,3);
cout << power(6.3,0)
cout << SumOfTwoHighest
return 0;
}
OUTPUT
CODE TO COPY
#include <iostream>
using namespace std;
int SumOfTwoHighest(int i, int j, int k)
{
int temp;
if(i > j)
{
temp = i;
i = j;
j = temp;
}
if(i > k)
{
temp = i;
i = k;
k = temp;
}
if(j > k)
{
temp = k;
k = j;
j = temp;
}
return j+k;
}
int main() {
cout << SumOfTwoHighest(1, 2, 3) << endl;
cout << SumOfTwoHighest(0, 1, 0) << endl;
cout << SumOfTwoHighest(-1, -2, -3) << endl;
}
PLEASE UP VOTE