Sum of Numbers #WSQ07 #TC1017
I’m so happy to show you how to sum N numbers! in a VERY SIMPLE EASY WAY!!
For starters Programming must be so easy and clear, try not to use many lines!! I decided to use a to counters to perform this operation. I Only use 3 variables, Int , one of them is a counter, so first I print what I want, and I read the variableA then I use DO- WHILE .
// Ale’s Code!! 🙂
#include <iostream>
using namespace std;
int main(){
int A, B, contador=1,suma=0;
cout<<” Please give us lower bond ” << endl;
cin>> A ;
cout<<” Please give us upper bond” << endl;
cin >> B ;
do{
suma=suma+A;
A= A+1;
} while(A<=B);
cout<< ” the sum from” << A << “to” << B << “is = ” << suma<< endl;
return 0;
}
#WSQ07 #TC1017 by Alejandra Jacobo Gómez is licensed under a Creative Commons Attribution 4.0 International License.