WSQ 04

--Originally published at Blog TC1017

Sum Of Numbers

I had some problems with this code especially in the part where I had to use the second while, the teacher explained this to me in a very easy way, you can see it in the comments in gray. This code sums the numbers from the first number or the lower bound to the last number or the upper bound.

Mastery Topics: 1)Use of comments, 13)Use of loops with “while” and “do while”

SumOfN


WSQ 04 – Sum of Numbers

--Originally published at MarizProfile

captura-de-pantalla-2017-09-18-a-las-13-21-29.png

In this activity, I had to ask the user for a range of numbers (between 2 values the user would give me), and sum all of the numbers that existed in the range. To do this, I had to use a While loop again. It was very simple, because the 2 independent values were the lower number and the higher number of the range, so that the 2 variables that changed in order to get the sum were “Suma” and “Num”. I had to use a variable “Num” that took the place of the lower number, so that the sum didn’t started by adding numbers from 0, but from the lower number of the range (Num= Num1).


WSQ 04 – Sum of Numbers (Week 05)

--Originally published at Ernesto's Computing Works

Para el programa numero 04 tuvimos que hacer que pidiera al usuario un rango de números, el primer numero era el limite inferior y el segundo era el limite mayor si el usuario los ponía al revés le marcaba error y le daba oportunidad de ponerlas de nuevo. Al obtener los dos rangos el programa te hacia una suma de todo los números que estuvieran dentro de ese rango. Este programa se me hizo muy fácil, ademas me gusto la dinámica, lo hice completamente solo, y usé comandos comunes que ya hacia usado anteriormente.

Screenshot 2017-08-31 19.17.03


WSQ 04 – Sum of numbers

--Originally published at Solving problems with programming

This was a little difficult to me because i only know how to use condiotionals and i have never work with loops, so i just only need to ask my professor how a loop works and that was it.

This is my github link where you can find my full code https://gist.github.com/jesuscmadrigal/ae8e994c569cb2ab2c9104dec8b07acd

Haga click para ver el pase de diapositivas.

WSQ 04 – Sum of Numbers

--Originally published at BRENDA

This week I completed the Sum of Numebrs Assignment.

For this task I used the Mastery Topic #13, loops with while and #8, importing and using libraries. I had some trouble at first because I did not know how to make the program do what I wanted, but after consulting with Ken I managed to do it.

This is the code I used:

#include <iostream>
using namespace std;
int main ()
{
cout << “I will calculate the sum of integers in the range you provide ” <<endl;
int low;
int high;
cout << “Please introduce the range “<<endl;
cout << “From: “; cin >> low;
cout << “To: “; cin >> high;
int x=low;
int total=0;
while ( x <= high ) {
total = total + x ;
x++;
}
cout << “The sum from “; cout << low; cout << ” to “; cout << high; cout<< ” is “; cout << total <<endl;
return 0;
}

The picture shows how the program works.

Captura1


Sum of Numbers

--Originally published at Valeria CT

I believe that this is the practice that I’ve struggled with the most and the longest. I tried doing what was asked through conditionals, recursion, functions, “while” loops, etc. I read How to think like a computer scientist again and again and did a lot of reasearch on the Internet. Finally, Damian helped me by explaining to me how a “for” loop works and I was able to write my code. I had a few syntax errors at first, but that didn’t take as long to correct.

Here are the resources that I used:

 

-Valeria


Suma de números

--Originally published at RON

Esta practica estuvo fácil, pues con los conocimientos que llevo hasta el momento mas la ayuda de mi libro y de mi profesor todo fue sencillo, solo tuve un percance, pues se me había olvidado darle el valor de 0 a la variable de suma. En la parte inferior dejo mi código .cpp para que lo chequen.

WSQ04.png

Enlace código .cpp:

https://drive.google.com/a/itesm.mx/file/d/0BwFGq6oJuVvVYV9hemhlZlJHM00/view?usp=sharing


Sum of Numbers

--Originally published at Programming in C++

Program:

For this program we have to ask for two range of numbers and the we are going to add the numbers that are in the range.

Imagen2

For this we use a “for”. With the loop “for” we have to put the integer, then the condition, and lastly we sum 1. What this is going is add a number to the variable until it satisfy the condition we put, so it will run for a certain amount of times.

Bash:

Imagen3