# Quiz 3

--Originally published at Solving problems with programming

In quiz number 3 we have to do 2 funtcions. The first on has to return the smallest number of 3 numbers that the user gives. You are going to use conditionals and  comparisons to get the samller number. But there is a problem, if there a two numbers that are equal and he the smallest you have to manege it. What I did is tell the user that are 2 numbers that are the smaller but are the same. I know there is another way to solve it better, I need to check the block of my classmates to find a better answer. The Second Function has to return the sum of the square of each number, this function is very easy.

Here is the code

#include
#include
using namespace std;
int minimumThree(int x, int y, int z){
if(x cout << “El número menor es= “;
return x;
} else if(y cout << “El número menor es= “;
return y;
} else if(z cout << “El número menor es= “;
return z;
} else if(z==y and z std::cout << “Hay dos números menores ” << endl;
}
}
int sumSquares(int x, int y, int z) {
int suma;
suma = pow(x,2)+ pow(y,2)+ pow(y,2);
return suma;
}
int main(){
int num1,num2,num3;
cout<< “Escribe número 1″<<endl; cin >> num1;
cout<< “Escribe número 2″<<endl; cin >> num2;
cout<< “Escribe número 1″<<endl; cin >> num3;
cout <<minimumThree(num1,num2,num3)<<endl;
cout <<sumSquares(num1,num2,num3)<<endl;
}  # Quiz 3

--Originally published at Solving problems with programming

In this quiz what we have to do is create two functions one that calcultes the root square of a variable and the other has to calculate the cubic square of a variable. For doing that we can use the library cmath, that already has the funcion to calculate cubic and root squares. If the number that the user is giving is negative it is imposible to calculate the root square so we are going to inform the user

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

double square_root(double x){
return sqrt(x);
}
double square_cube(double x){
return cbrt(x);
}

int main(){
double num,r2,r3;
cin >> num;
if (num<0) {
cout << “La raíz cúbica del número es ” <<square_cube(num)<<endl;
} else {
r2= square_root(num);
std::cout << “La raíz cuadrada del número es ” << r2 <<‘\n’;
r3= square_cube(num);
std::cout << “La raíz cúbica del número es ” << r3 << ‘\n’;
}
}  # Quiz #3 – Square and cube roots of a number.

--Originally published at |Blogging through my thoughts|

For this task , my classmates and I were instructed to create a program that asks the user for a number and then calls functions to calculate the square and cube roots of a number and prints them out.

For this quiz , I created the program with two functions:

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

-Important notes:

• I had to add a new library to my program , in order to use the square and cube roots functions:

#include <cmath>      // Declares a set of functions to compute common mathematical operations.

• The progam does not accept negative numbers. It asks again for a positive number.

Here you will find my code and some captures:

#include <iostream>
#include <cmath>      // Declares a set of functions to compute common mathematical operations.
using namespace std;

double x;

double square_root (double x) {
double square_root = sqrt (x);
return square_root;
}

double cube_root (double x) {
double cube_root = cbrt (x);
return cube_root;
}

int main(){
cout << “This program calculates the square and cube roots of a number.”<< endl;
cout << “Give me a number:”<< endl;
cin >> x;

if (x<=0){
cout << “Please , insert a positive number.”<< endl;
}else{
cout << “The square root of ” << x << ” is ” << sqrt (x) << endl;
cout << “The cube root of ” << x << ” is ” << cbrt (x) << endl;
}
return 0;
}

Until next time.

°Luis Felipe Garate Moreno.  # int Square & Cube Root // Quiz Week 03

--Originally published at Alvaro_246

# Quiz 03

In this Quiz I made a program to calculate de square root and cube root of a especific number, I worked with math funtions, I used the library <cmath> beacuse I need to use Math operations the funtion are “sqrt and cbrt” and one “if” because the program don’t calculate negative numbers (-x) and the program prints “Error, Don’t use negative numbers” This is my Code :

#include <iostream>
#include <cmath>

using namespace std;
double square_root (double x) {
double square_root = sqrt(x);
return square_root;
}
double cube_root(double x) {
double cube_root = cbrt(x);
return cube_root;
}
double x;
int main() {
cout << “This Program calculate the Square and cube root of a specific number” << endl;
cout << “Insert a number”<< endl;
cin >> x;
if (x<=0){
cout << “No negative numbers”<< endl;
}
cout <<“square root is: “<< square_root(x)<<endl;
cout <<“cube root is : ” << cube_root(x)<< endl;
return 0; // Alvaro_246
}  # There was quiz today?!

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:  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: #### I know it’s a little late, but I swear I did it in class.  # Surprise surprise… Quiz#3 (corrected)

--Originally published at OlafGC

(This post is edited and has the correct and ultimate version of the code at the very end, with a new entry)

Do you feel like you want to burn your computer to ashes each time your code is not compiling because of a simple “;”? Am I the only one, for real? Yes, today we had a quiz (and I wasn’t there, to make it worse). The quiz consists on making a program that will give you the square and cubic root of any number you plug into it. Pretty easy concept…  if you have read at least to chapter 3 in your book.

I’m presenting this quiz at this hour because I know that I acquired the knowledge required, and to me it’s all that matters. I did not just copied a piece of code from another partner.

After a freaking lot of few mistakes, my program runs correctly, so here it goes, photo and text code:

#include<iostream>

#include <cmath>//this for including the math library for functions
using namespace std; //automatically gives a space after finishing each line
//You have to tell the computer what are the variables(declare them) and assign an operation
double square_root(double number)
{
return sqrt(number);
}
double cubic_ro

ot(double number)
{
return cbrt(number);
}
//Once you’ve declared all variables, you start writing the “visible code” (term made up by myself)
int main ()
{
int number;
double resquare, rescubic; //Name the variables you declared before
cout<<“I will give you the square and cubic root of any positive number you give me:”<<endl; cin>>number;
if(number>0) //here we set the condition a number must accomplish in order to be solved
{
resquare – square_root(number);
cout<<“The square root of that number is ” <<resquare<< cout<<“.”<< endl; //nice and tidy
rescubic – cubic_root(number);
cout<<“The cubic root of that    Continue reading "Surprise surprise… Quiz#3 (corrected)"

# Quiz week 3

--Originally published at TC1017

The quiz from week 3 consisted in making a program that calls 2 functions in order to print the square and cube root of a number given by the user. I used the library <cmath> to be able to call the square and cube root functions, and then call them when printing the results. The program is below.  #quiz03    # Quiz 3

--Originally published at RAMGGV

En este quiz el profesor nos pidió que hiciéramos un programa que pudiera calcular tanto la raíz cuadrada, como la cubica del mismo numero. Para esto utilice variables tipo double y así tener una mayor precisión sobre el resultado. El programa lo hice lo mas sencillo posible para poder entenderlo más fácilmente.  # Quiz #3

--Originally published at TC1017 Programing Curse

For this quiz, i have to do a program that, ask the user for a number to obtain the square root and the cubir root of the number.

At first i declare the variables, well just one variable, that it is going to be x, (the number that the user will introduce), then after the number is asked, i use an if, this because the number it’s negative, the square root does not exist, so the if is for that case, and i used an else to print that the square not exist, and then print the cubic root.

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

double x;

int main (){
cout << “Escribe el numero al que deseas sacarle raices” << endl;
cin >> x;
if (x>=0)
{
}
else {
cout << “N/A” << endl;
}
cout << “la raiz cubica es ” << cbrt(x) << endl;
return 0;
}  # Quiz #3

--Originally published at Programming 101

Hello guys! Today we had our third quiz and basically it was about wiritting a program that returned the square and the cubic root of a number. In the possible scenario that the user typed in a negative number, the program is supposed to give an appropriate answer.

Well, here is my code and the run program with the two possible outcomes, the one when the program gives the square and cubic root of a number and the one when the program receives a negative number.

Cheers, everyone! Stay awesome.    