for loop calculate the total of the numbers between two numbers, inclusive
1
Expert's answer
2011-12-20T09:29:52-0500
# 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(); }
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment