#Quiz05

Hey guys, I’m here with another quizz, let’s take a check to our to do list:

  1. Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).
  2. Create a function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors, you will need an additional parameter to represent the number of numbers in the array. So if the list was [0,4,2,6,9,8,3,12], the function would return 30 (0+6+9+3+12).

Let’s do it:

First function:

prog1Quizz5

Second function:

prog2Quizz5

You’re welcome.

#WSQ11 – Yo Soy 196

To do list:

Your jobs is to create a program that asks the user for two pieces of data:

  • The lower bound of the sequence
  • The upper bound of the sequence
Then you check the values from the lower bound (inclusive) to the upper bound (inclusive) and make a report of them. During the analysis of each number, if a Lychrel number is found it should be reported immediately with something like “Found a Lychrel number: 196”
The report must show:
  • The range of numbers analysed (lower to upper bound)
  • The number of natural palindromes (no addition to inverse needed)
  • The number of non-Lycherels encountered (become palindromes)
  • The number of Lycherel number candidates (that did not converge to palindrome)

Since you will not be able to prove that a number is Lycherel (since you cannot computer forever to check), our definition for a Lycherel candidate will be if a number does not converge after 30 iterations of applying the addition to the inverse.

Ok, people, I know, this task is kind of insane, but let me show you my program (I needed a lot of help on this one):

WSQ111

 

Second part of the program:

WSQ112

 

Third and (thank God) last part:

WSQ113

 

The results:

WSQ11F

Really hard one. Let’s move.

 

#WSQ10 – Lists

All right people, here’s what we need to do:

  • Create a program that asks the user for 10 numbers  (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.

Easy code, let me show you:

WSQ10

Don’t forget to import “statistics”, so you can not call stdev and pstdev commands.

Let’s keep moving.

#WSQ09 – Factorial Calculator

Hey people, it’s been such a long time since my last post, but, I’m back.

As always, here’s what we need to do:

  • Create a program that asks the user for a non-negative integer (let’s call that number n) and display for them the value of n! (n factorial).
  • After showing them the answer, ask them if they would like to try another number (with a simple y/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered n).

So, let’s begin:

WSQ09

Not a difficult code, but it’s a little long, if you have any question about my code, just ask below in the comments section.

Let’s move.

#WSQ7

Well fools this is my last post of this first period. and will be about making a program that add a range of numbers. For example the range is 2 to 4, so the sum will be 2+3+4=9. so this program could make the sum for any range of integers numbers.

Now I am going to explain how I did it. First, as always I declare my variables, in this case I used num1 one (for the lowest number in the range), num2 (for the highest number in the range) and sum, witch will have a value of 0 at the beginning of the program. Then I used a do while loop witch will work until num1 is >= num2. And while this condition is true, the program will do this simple math. As I said sum at the beginning will be 0, then it would do the mat and then it would have the value of the result. As you can se after we did this operation, you add 1 to num1 until the condition is true.

Here is the link for you to download my code:

https://www.dropbox.com/s/1tsc0vzsx8cp5fh/suma.cpp?dl=0

Thanks fools!!

Captura de pantalla 2016-02-18 a las 10.19.08 p.m.imagen thanks

#WSQ06

Hi there, this new post is about doing a program that generates a random number between 1 and 100 and you have to guess it. It´s a game, it is fun, I have been playing for hours with my code. This code was complicated because you have to use some new things, such as libraries that you often do not use. I made some comments in my code for you to understand what I was doing, or what it suppose to do that part of the code. So as I say it was a little bit complicated and I have to look up for some information on the internet. So this code it is a little bit complicated for me to explain it with words, so I am going to put the video where I learn how to do it.

Thanks fools!!

Heres is the link of the video:

And here is the link of my code. I beg you to download it and play with it, it is very fun:

https://www.dropbox.com/s/82tohs4ryo5rw1v/1.cpp?dl=0

Captura de pantalla 2016-02-18 a las 9.28.28 p.m.imagen thanks

WSQ09 – Factorial Calculator

el código:

#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int num,resul,x,fin;
char sig;
do
{
resul=1;
cout<<“nDamen un numero para hacer factorial: “<<endl;
cin>>num;
fin=num;
for(x=1; x<=fin; x++)
{
resul=resul*x;
}
cout <<“nEl resultado es “<<resul;
cout <<“n¿Quieres otro numero? si=s, no=n”<<endl;
cin>>sig;
}while(sig==’s’);
cout <<“nGracias, que pases buenas noches.”;
getchar();
return 0;
}

WSQ07 – Sum of Numbers

el código:

#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main()
{
int num1,num2,rest,resul,x;
resul=0;
cout<<“nWe will calculate the sum of integers in the range you provide.”;
cout<<“nPlease give us the lower bound: “;
cin>>num1;
cout<<“nPlease give us the upper bound: “;
cin>>num2;
rest=num2-num1;
for(x=0; x<=rest; x++)
{
resul=resul+num1;
num1++;
}
cout <<“nEl resultado es “<<resul;
getchar();
return 0;