0

Beginner Question

Create a function that takes two numbers as arguments and returns their sum.Examples addition(3, 2) ➞ 5 addition(-3, -6) ➞ -9 addition(7, 3) ➞ 10

2nd Aug 2023, 4:25 PM
NkO
7 Antworten
+ 5
NkO , just a general comment to your post: your questiom seems to be incomplete. the post should include: > the programming language (to be placed in tags) > the name of the tutorial and the lesson name (if your question is related to o sololearn tutorial or a code coach exercise) > a complete task description > a link that points to your code try > a description what exactly your issue is, (if possible including an error message)
2nd Aug 2023, 4:52 PM
Lothar
Lothar - avatar
+ 2
NkO What is your question?
2nd Aug 2023, 4:36 PM
Junior
Junior - avatar
+ 2
NkO Close, that is one way but your problem doesnt follow your solution, something like this should help you: define addition(first_number, second_number) add first_number + second_number return sum print and call addition(2, 3)
2nd Aug 2023, 4:44 PM
Junior
Junior - avatar
+ 2
def addition(a,b): return a+b print(addition (3,2))
3rd Aug 2023, 2:34 AM
Sam Attal
Sam Attal - avatar
+ 1
a = 2 b = 3 sum = 2+ 3 Print(sum) I just want to know if I am on track with my solution.
2nd Aug 2023, 4:39 PM
NkO
+ 1
Thank you Junior & Sam Attal !
3rd Aug 2023, 3:32 AM
NkO
+ 1
NkO in c++ it function can be :- #include<iostream> using namespace std; int func(int x,int y){ return x+y; } int main(){ int x,y; cin>>x>>y; cout<<func(x,y);
4th Aug 2023, 3:48 PM
Alhaaz
Alhaaz - avatar