+ 1
Write a program that takes two numbers as input, assigns those values to the provided a and b variables, then outputs their sum.
Please let me know where i went wrong!!!!!! #include <iostream> using namespace std; int main() { int a; int b; int sum; cout << "Enter the value a:"; cin>> a; cout<<"\nEnter the value b:"; cin >> b; sum=a+b; cout<< "\nThe sum is:"<<sum ; return 0; }
7 ответов
+ 6
_pfttwdyc_ ,
i assume that your question is a code coach exercise. please note:
▪︎all code coach exercises are tested by a program that passes values for the various test cases and that receives results from the code.
this will work perfectly, as long as only the demanded inputs and / or outputs are used in our codes.
▪︎so please do not use any *user prompt* in your code, and only print the required results without any additional output.
+ 4
Try to comment the lines that prints input prompts ("Enter the value ...")
And print <sum> only, without "\nThe sum is ..."
+ 3
What correction is needed? the code works as expected ...
Please use proper tags ... ☝
https://code.sololearn.com/W3uiji9X28C1/?ref=app
+ 2
This code is right.
You have to give input like this in sololearn:
Input...
x (say)
y (say)
+ 1
Oops I thought it was not a code coach problem 🙄
+ 1
#include <iostream>
using namespace std;
int main() {
int a;
int b;
// your code goes here
cin>> a>>b;
int sum=a+b;
cout<<sum;
return 0;
}
0
But the result says to try again and something went wrong