63 193
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #5699 in C++ for Michael Copple

Question #5699
for loop calculate the total of the numbers between two numbers, inclusive
Expert's answer
# include<iostream.h>
# include<conio.h>

int b,a,n,i;

void main(){
cout<<"Enter first number: ";
cin>>a;
cout<<"Enter second number: ";
cin>>b;
n=0;
if (b>=a)
& for (i=a;i<=b;i++) n++;
else
& for (i=a;i>=b;i--) n++;
cout<<"total of numbers between "<<a<<" and "<<b<<" is "<<n<<" (inclusive)\n";
getch();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions