Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This code is not working properly, could you please check it out. I have been trying to solve it The sum of all integers between
This code is not working properly, could you please check it out. I have been trying to solve it
The sum of all integers between n1 and n2 inclusively
- Ask the user to enter two numbers, n1 and n2, using the int data type.
- Using any looping mechanism (determine which loop works best), calculate the sum of all numbers between n1 and n2
cout << "Enter a number:";
cin >> n1;
cout << "Enter a number:";
cin >> n2;
for(i = n1; i <= n2; i++)
{
sum += i;
}
cout << endl;
cout << "SUM: "<< sum << endl;
cout << endl;
break;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started