Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/feed-rss2.php on line 8
‘Vectors’ Articles at TC101 Fall 2015 https://kenscourses.com/tc101fall2015 Introduction to Programming Python and C++ Wed, 21 Oct 2015 23:07:07 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Quiz #8! https://kenscourses.com/tc101fall2015/2015/quiz-8-8/ Wed, 21 Oct 2015 23:07:07 +0000 http://myfreakingcrazythoughts.wordpress.com/?p=137 Continue Reading →]]> Hello again!

For today’s quiz we had to write a code which could ask the user for undeterminated number of values and calculate the sum of the squares.

For example:

Let’s suppose that the user will introduce this values to the program:

1, 2, 3, 4, 5.

Now, what the program will do is the following:

1^1+2^2+3^3+4^4+5^5 and it will print 55

When we want to stop giving values to our program it is indicated that the user must have to type 0.

So, everything will look like this:

//Sum the Squares of an undeterminated number of values
#include <iostream>
#include <vector>
using namespace std;

int sumsquares_list (vector<int> v){
int len = v.size();
int sum = 0;
for(int i = 0; i < len; i++) {
sum= sum + (v[i]*v[i]);
}
return sum;
}

int main()
{
int c;
vector<int>v;
cout<<"Please introduce a serie of values and write 0 to finish."<<endl;//0 will be the signal to stop asking for values
cin >> c;
while(c != 0) {
v.push_back(c);
cin >> c;
}
cout<<""<<endl;
cout<<"  The sum of the squares of the numbers that you typed in is: "<<sumsquares_list(v)<<endl;
return 0;
}

And the execution of the program will look just like this:

Quiz8 execution

And, if you want to see my codes on GitHub, remember, just clic HERE.

Have an awesome week!

-The Admin

]]>
https://creativecommons.org/licenses/by/4.0/
Quiz #8! https://kenscourses.com/tc101fall2015/2015/quiz-8-16/ Wed, 21 Oct 2015 23:07:07 +0000 https://myfreakingcrazythoughts.wordpress.com/?p=137 Continue Reading →]]> Hello again!

For today’s quiz we had to write a code which could ask the user for undeterminated number of values and calculate the sum of the squares.

For example:

Let’s suppose that the user will introduce this values to the program:

1, 2, 3, 4, 5.

Now, what the program will do is the following:

1^1+2^2+3^3+4^4+5^5 and it will print 55

When we want to stop giving values to our program it is indicated that the user must have to type 0.

So, everything will look like this:

//Sum the Squares of an undeterminated number of values
#include <iostream>
#include <vector>
using namespace std;

int sumsquares_list (vector<int> v){
int len = v.size();
int sum = 0;
for(int i = 0; i < len; i++) {
sum= sum + (v[i]*v[i]);
}
return sum;
}

int main()
{
int c;
vector<int>v;
cout<<"Please introduce a serie of values and write 0 to finish."<<endl;//0 will be the signal to stop asking for values
cin >> c;
while(c != 0) {
v.push_back(c);
cin >> c;
}
cout<<""<<endl;
cout<<"  The sum of the squares of the numbers that you typed in is: "<<sumsquares_list(v)<<endl;
return 0;
}

And the execution of the program will look just like this:

Quiz8 execution

And, if you want to see my codes on GitHub, remember, just clic HERE.

Have an awesome week!

-The Admin

]]>
https://creativecommons.org/licenses/by/4.0/
Roll the DIEZI read the book and looked at some websites to… https://kenscourses.com/tc101fall2015/2015/roll-the-diezi-read-the-book-and-looked-at-some-websites-to/ Wed, 21 Oct 2015 00:36:00 +0000 http://opezaimd.tumblr.com/post/131587844440

Roll the DIEZ

I read the book and looked at some websites to complete my understanding about vectors and arrays.

Websites:

 http://www.cplusplus.com/reference/list/list/

https://www.programarya.com/Cursos/C++/Estructuras-de-Datos/Arreglos-o-Vectores

Code

]]>

Roll the DIEZ

I read the book and looked at some websites to complete my understanding about vectors and arrays.

Websites:

 http://www.cplusplus.com/reference/list/list/

https://www.programarya.com/Cursos/C++/Estructuras-de-Datos/Arreglos-o-Vectores

Code

]]>
https://creativecommons.org/licenses/by/4.0/