C++ Functions (Sum of numbers) | Set 1 | Practice | GeeksforGeeks

Given three numbers A, B, C you have to write a function named calcSum() which takes these 3 numbers as arguments and returns their sum.
Input: 
The input line contains T, which denotes the number of testcases. Then T test cases follow. Each test case consists of a single line which contains three space separated integers A, B, and C.
Output:
Corresponding to each testcase, output sum of A, B and C in a new line.
User Task:
Since this is a functional problem you don't have to worry about input, you just have to complete the function calcSum().
Constraints:
1 <= T <= 105
1 <= A <= 102
1 <= B <= 102
1 <= C <= 102
Example:
Input:
3
1 2 3
5 6 7
2 5 3
Output:
6
18
10
Explanation:
Testcase 1: Sum of the given 1,2 and 3 is 6.
0
rohitpandey484Premium1 week ago
What is the issue of this logic like 
if we will use 
int x=a+b+c;
int y=a+b+c;
int z=a+b+c;
return calSum(x,y,z)
-1
0niharika22 months ago
return a+b+c;
0
bhargabeesahoo2000Premium2 months ago
int calcSum(int a,int b,int c){   int sum;   sum=a+b+c;   return sum;
}
-1
helloutkarsh983 months ago
int calcSum(int a, int b, int c)    {   return (a+b+c);}
0
tushargarg98683 months ago
// { Driver Code Starts#include <iostream>using namespace std;
int calcSum(int a,int b,int c);
int main() {int t;cin>>t;while(t--){    int a,b,c;    cin>>a>>b>>c;    int sum = calcSum(a,b,c);    cout<<sum<<"\n";}return 0;}// } Driver Code Ends
/*  Write your function here */
/* The function should be named calcSum   and accepts three parameters of integer type   and returns the sum of the three integers */   int calcSum(int a, int b, int c)    {   // Your code here   int s=0;   s=a+b+c;   return s;}
-2
gauravbhakuni093 months ago
#include<iostream>
using namespace std;
int main(){
 
-2
20ce020064 months ago
int calcSum(int a, int b, int c)    {   return a+b+c;   // Your code here}
-1
looser6 months ago
int calcSum(int a, int b, int c)    
{
   return a+b+c;
   // Your code here
}
-2
kumarabhaydaan6 months ago
#include <iostream>
using namespace std;
int main()
{    int a,b,d,c,x,e,y,z;
   
     cout<<" enter any three digit number :";
     cin>>x;
     cout<<" enter any three digit number :";
     cin>>y;
     cout<<" enter any three digit number :";
     cin>>z;
     a=x%10;
     b=x/10;
     c=b%10;
     d=b/10;
      e=a+c+d;
  cout<<"\n  the sum of the three digits is: "<<e;
   a=y%10;
     b=y/10;
     c=b%10;
     d=b/10;
      e=a+c+d;
  cout<<"\n the sum of the three digits is: "<<e;
   a=z%10;
     b=z/10;
     c=b%10;
     d=b/10;
      e=a+c+d;
  cout<<" \n the sum of the three digits is: "<<e;
     return 0;
 
}
-4
tushartxts7 months ago
1
2
3
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.