Quiz 4

--Originally published at Tec Life

For this quiz we have to do this:

For this quiz I want you to (in class) create a program with two functions:

  • int minimumThree(int x, int y, int z){ }  // returns the value that is smallest of x, y and z
  • int sumSquares(int x, int y, int z) {}  // returns the value of the sum of squares of x, y, z

You should make a main routine that asks the user for three numbers and then calls your functions to which should *RETURN* the value and you print in the main program.

So I started writing my program normally, declaring my variables, naming my functions and to make the user to write the three numbers.

captura-de-pantalla-2017-02-02-a-las-09-28-40

Then I make what my functions would do, that says in the first function that I am going to multiplied my variables with the function “pow” and in a parenthesis my variable “,” and the number I want to multiplied my variable, in this case 2 for square and the sum the operations.

And on my second function I put conditions with if and else to make the program know what number is bigger than the other and finally printed on the result.

captura-de-pantalla-2017-02-02-a-las-09-28-52Image from: http://www.quizfactor.com/quiz/general-knowledge/5

#Quiz04


Suman y suman y vuelven a sumar ♪♫

--Originally published at Adal´s Blog

La actividad de esta semana es:


La actividad consiste en crear un código el cual nos ayude a sumar un rango de valores dado


Este problema lo resolví con un ciclo un while para así obtener la sumatoria de los números  

Personas de ayuda:
  • Sandoval A.

There was quiz today?!

--Originally published at Loading…

Yes, today we did our 3rd quiz, and it was… “easy”? At first, when I read what we have to do my face was a little like this 😕 because I didn’t read the chapter 3 and I don’t have idea what I have to do, but Ken show us a code, I Googled and compared it with some of the codes that my classmates had in their blogs, at the end I understand what I was doing with all that. This is my code:

qp qp2

First I had to add the <cmath> library in order to make my functions works, the square and cube root functions. Also I used double for my variables, so it could give me decimal numbers, I declared everything like the ecuation and the cout. After I add a if fuction, if the number that the user gives was negative, then a do/while start, so it ask for a new number, and a nesting of conditional statements for if the case repeats (negative number).

And this is how it runs:

qp3

I know it’s a little late, but I swear I did it in class.


Cómo quiere su raíz

--Originally published at Adal´s Blog

La actividad dice así:


Para poder usar este programa necesitamos acudir a expresiones matemáticas alternas, como por ejemplo, expresar la raíz cuadrada en forma de potencia y utilizar nuevas librerías (en este caso <cmath>)

Y así es como queda el código:


Pagina de ayuda;

#Quiz03

--Originally published at Solving Problems with Programming

PICTURE OF AUTOR

THIS IS THE #QUIZ03 WHOSE OBJECTIVE IS CREATE AND CALL FUNCTIONS TO DO DIFFERENT TASKS AT DIFFERENT TIMES. COVERING #MASTERYTOPIC06 #MASTERYTOPIC07 .

This #QUIZ03 makes a main routine that asks the user for a number and then calls your functions to calculate the square and cube roots of that number and prints them out. And if the number given is negative. It is going to print the cube root number but in the square root it will tell the user that the number given for that root is IMAGINARY! (#Mastery11).

FIRST TO DO THIS #QUIZ03 I HAVE TO USE THE LIBRARY FOR THE COMMANDS OF MATH THAT WOULD BE SQRT FOR SQUARE ROOT AND CBRT FOR THE CUBE ROOT AND I FOUND THE NAME OF THE LIBRARY IN THE BOOK OF THE COURSE THAT IT IS CALLED #include<cmath>:

library

Link of the book that told me the name of the math library: How to Think Like a Computer Scientist C++ Version by Allen B. Downey.

And also for the name of the commands i used for information this link: function <cmath> cbrt and this link: function <cmath> sqrt

cube2

PICTURE OF AUTOR

funx

PICTURE OF AUTOR

SO AT FIRST THING YOU DO THE SAME AS OTHER PREVIEW CODES DECLARATE YOUR TYPE OF VARIABLE AND YOUR VARIABLE AND ASK THE USER TO GIVE YOU A NUMBER.

AFTER THAT YOU HAVE TO CALL YOUR CREATED FUNCTIONS THAT WERE:

  • double square_root(double x) {}  // returns the square root of x
  • double cube_root(double x) {} // returns the cube root of

YOU HAVE TO KNOW THAT USING THESE 2 FUNCTIONS IS OTHER EXTERNAL FUNCTIONS FROM THE MAIN THAT HAS A DOUBLE FUNCTION VALUE OF 64 BITS AND DECLARING A DOUBLE VARIABLE X INSTEAD OF USING THE VOID MAIN THAT HAS 0 BITS.

TO CALL THE FUNCTION IN THE MAIN

new
Continue reading "#Quiz03"

I finished the quiz in time!!

--Originally published at Programming Path

Well, maybe I took me more time because of writing the post, but!!! I did it! I’m proud of myself!

We had to do a program with two specific functions:

  • double square_root(double x) {} ; // returns the square root of x
  • double cube_root(double x) {} ; // returns the cube root of x

The program needs to ask what number do you want to be x and the program will respond with it’s square root and it’s cube root.

For this, we have to add a function to the program and that was the challenge, at least for me, because I didn’t knew how does a function works and even less how to add it to the code. That is why I ask for help to my classmate Sergio. He was very helpful, thank you Sergio!!

This is what I did:

quiz3

and here is outside the photo:

#include <iostream>
#include <cmath>
using namespace std;

double square_root (double);
double cube_root (double);
int main () {
double x, s, c;
cout << “I will give you the square and cube root of x. What is x? “;
cin >> x;
s = square_root (x);
c = cube_root (x);
cout << “Square root: ” << s << endl;
cout << “Cube root: ” << c;
return 0;
}
double square_root (double x) {
return sqrt (x);
}
double cube_root (double x) {
return cbrt (x);
}

So, the first thing I always do is insert the <iostream> and the namspace std. This time I added the library of the math functions which is <cmath>, because we will need it to solve the square and cube roots. I also add the values of them: double square_root (double);
double cube_root (double). What I understood was that we need to add this so

Continue reading "I finished the quiz in time!!"