Solve Me First – HackerRank Solution

Solve Me First – HackerRank Solution

Problem :

Complete the function solveMeFirst to compute the sum of two integers.

Function prototype :

int solveMeFirst(int a, int b);

where,

  • a is the first integer input.
  • b is the second integer input

Return values :

  • sum of the above two integers

Sample Input :

a = 2
b = 3

Sample Output :

5

Explanation :

The sum of the two integers a and b is computed as: 2 + 3 = 5.

Solution :

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int solveMeFirst(int a, int b) {
    int sum = a + b;
    return sum;
}

int main() {
  int num1, num2;
  int sum;
  cin>>num1>>num2;
  sum = solveMeFirst(num1,num2);
  cout<<sum;
  return 0;
}

 216 total views,  1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *