I AM REALLY BEHIND IN THE READING, SO THIS QUIZ WAS HARD FOR ME. I NEEDED TO ASK A FRIEND OF MINE TO HELP ME.HE EXPLAINED TO ME AND THEN IT WAS EASIER.
LINK TO CODE: https://github.com/cortesivan96/Sum-of-Squares/blob/master/Quiz%208
]]>I AM REALLY BEHIND IN THE READING, SO THIS QUIZ WAS HARD FOR ME. I NEEDED TO ASK A FRIEND OF MINE TO HELP ME.HE EXPLAINED TO ME AND THEN IT WAS EASIER.
LINK TO CODE: https://github.com/cortesivan96/Sum-of-Squares/blob/master/Quiz%208
]]>QUIZ 8.
This was not that hard, but I couldn’t do it at first because I didn’t know how to use vectors, so I had to look for some information about that. This was a short quiz. Here is my code: https://github.com/bsolisale/QUIZ-8/blob/master/Q8
]]>QUIZ 8.
This was not that hard, but I couldn’t do it at first because I didn’t know how to use vectors, so I had to look for some information about that. This was a short quiz. Here is my code: https://github.com/bsolisale/QUIZ-8/blob/master/Q8
]]>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:
And, if you want to see my codes on GitHub, remember, just clic HERE.
Have an awesome week!
-The Admin
]]>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:
And, if you want to see my codes on GitHub, remember, just clic HERE.
Have an awesome week!
-The Admin
]]>Here is my code to quiz 8,
Programming is way more fun when you begin to actually get it.
Thanks
#Quiz08 #QUIZ8 #TC1017 #KensCourses
]]>
Here is my code to quiz 8,
Programming is way more fun when you begin to actually get it.
Thanks
#Quiz08 #QUIZ8 #TC1017 #KensCourses
]]>
thanks ken
Here is my code
]]>thanks ken
Here is my code
]]>