Problem (Make Avg) - Solution

include
using namespace std;

int main()
{
int t;
cin >> t;
while (t–)
{
int a, c;
cin>>a>>c;
int b = a+c; // store the sum of int a and c

    if(b%2==0){   // check whether the sum is even or not
        cout<<b/2<<endl; // print average value of user input
    }
    else{         // print -1 if average value is float/double datatype 
        cout<<-1<<endl;
    }

}
return 0;

}

1 Like

include
using namespace std;
int main(){
float a,b;
cin>>a>>b
print((a+b)/2) // it will give you the average value of two numbers
}

i can do this code in python for you:
T=int(input()
for i in range(T):
A,B=map(int,input().split())
C=(A+B)
if(C%2==0):
print(C/2)
else:
print(-1)

i did not use indendation here since it was text based,you can add indendations in the coding software…thanks