Solve Me First | HackerRank Solution | Using c++


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

Example:

a = 7

b =3

Return 10

Function Description

Complete the solveMeFirst function in the editor below.

solveMeFirst has the following parameters:

  • int a: the first value
  • int b: the second value
Returns
- int: the sum of  a and b

Constraints

1<=a,b<=1000

Sample Input

a = 2
b = 3

Sample Output

5

Explanation

2+3=5.

Solution:

Code in C++ 

#include<iostream> using namespace std; int main(){ int a,b; cin>>a>>b; cout<<a+b; return 0; }

Code in C 


#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int solveMeFirst(int a, int b) { return a+b; } int main() { int num1,num2; scanf("%d %d",&num1,&num2); int sum; sum = solveMeFirst(num1,num2); printf("%d",sum); return 0; }

 

Sajal Gupta

Hi, i am sajal.I am a hardworking engineering graduate specialised in Computer Science Engineering ... Along with my degree, I completed C/C++,.Net,Java and SQL courses From Youtube and Other sources and various technologies.I learnt helped me develop my final year project called Code4xU..

Post a Comment