Temperature #WSQ02

--Originally published at It's me

I did this program a week ago but I’m uploading it now, sorry. This program was easy to do. First you declare your variables, like in any program, then you start. Ask the user for the temperature in Fahrenheit and with the simple operation of “celsius=5*(fahr32)/9;” you convert the temp into Celsius. The next part was to print, depending of the temperature, if waters boils or not. I made that with an IF and ELSE. Here’s the code:

codewsq02

And this is the program running:

wsq02


#Quiz04

--Originally published at It's me

I did it! It was hard for me to  find the solution but once I knew how to do it I did it “easily”. This assignment was similar to quiz 3, we needed to create functions and use them to print results. This time one function had to print the minimum value of three numbers; the other function had to sum the square of the same three numbers. The code of the first function was:

       int minimumThree(int x, int y, int z){
int minimumThree;
if(x<=y && x<=z)
minimumThree=x;
else{
if (y<=x && y<=z)
minimumThree=y;
else{
minimumThree=z;
}
}
return minimumThree;
}

It was a little complicated and long because I had to evaluate each value for the computer to save the smallest. Ken told me to use <= in the if because if I had the same number in two or the three values, the function will work.

The other function was easy, all I needed to do was to calculate the square roots and do the sum. The code of this function was:

      int sumSquares(int x, int y, int z) {
int sumSquares;
sumSquares=sqrt(x)+sqrt(y)+sqrt(z);
 return sumSquares;
}

This is the complete code (there’s no image because the complete code doesn’t fit):

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

int minimumThree(int x, int y, int z){
int minimumThree;
if(x<=y && x<=z)
minimumThree=x;
else{
if (y<=x && y<=z)
minimumThree=y;
else{
minimumThree=z;
}
}
return minimumThree;
}

int sumSquares(int x, int y, int

quiz4
Continue reading "#Quiz04"

Fun with numbers! #WSQ1

--Originally published at It&#039;s me

This was the first assignment. It’s not a difficult program, basically you just declare the variables, ask for numbers and write the operations using the variables. To print something, you need to use cout<<then you write what you want in quotation marks like: “Give me a number: “ then add <<endl; for ending that instruction. If you want that information in the variable, you write bellow: cin >> num1;. There you go, then you can do operations with the variables now that they have already a value.

Here’s my code: 

wsq1

Original header photo recovered from: https://www.flickr.com/photos/andymag/27853932732/in/photolist-JrmFMw-7XEruh-DNnYH-fmHjf2-7Dpz8d-6358Sy-9mqFmA-a1DxLo-m3CPo-jWGuhC-mTjBQ-5pf3JR-6q7D14-9v4CfC-buw58e-7ixpfM-pnNLmy-qJyamo-pEgSWu-9A6rSx-pnMNrB-9tM3Lx-oHqqL6-eoTrMt-9tQ1qE-fYfgZq-6Smdj9-58TTn-qAzegD-iQhVK-pxqEHB-ueG6r-hFp2Eu-5sgPYY-DNo1o-2iFRNG-qTcBuT-cX7HFS-6aPq1r-kmyjdw-egj6Vj-HRAx1C-Avope-qSmK2h-9BdSzK-QiWTJt-wtPhA-5pKQyP-eeetA6-oHqozy


#Quiz03

--Originally published at It&#039;s me

Functions! Basically we needed to use two functions: Square root and cube root. The mastery topics used for the functions were #MasteryTopic06 and #MasteryTopic07. Calling and creating functions, in the code you need to declare the function and it’s value for it to work, like the following:

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

For this you also needed a library, I used  #include <cmath> for the square and cube root to work. #MasteryTopic08. With this library you just could do the operations and not creating functions, but that wasn’t the point of the quizz. I used an if with else to validate the number because the roots can’t apply for negative numbers. Here is the code and a picture:

#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<<“Hey you! Wanna calculate the square and cube root of a number?”<<endl;
cout<<“Give me a number: “<<endl;
cin>>x;
if (x<0){
cout<<“ERROR! It’s not a valid number.”<<endl;
} else{
cout<<“The square root of “<<x<<” is: “<<square_root(x)<<endl;
cout<<“The cube root of “<<x<<” is: “<<cube_root(x)<<endl;
}
return 0;
}

quiz3

I run the program with 3 different values just to see how it works.

Original gif at the top recovered from: https://www.tenor.co/view/friends-phoebe-ross-rachel-gif-3394823


Hello Beautiful World! (First post)

--Originally published at It&#039;s me

This is my first time programming in C++. The course is different but I think I’ll learn a lot and at the same time enjoy it.

First, I had to install two tools or applications to create my programs. The first one is called “Atom” where I can write my code, it was very easy to install, the another is ubuntu for Windows 10, which is a Windows Subsystem for Linux. Although there was a step-by-step installation of the Linux Bash Shell, I had a lot of trouble because of a simple mistake of writing wrong a letter. I researched about how to use the terminal and finally find answers. I created a username and run my code. I had errors on finding the file but using the command “cd” I could change the directory where my file was.

2

3

You’ll see that I tried a lot but I learned and finally made it! Now I’m ready for more.

 

The original image at the beginning of the post is from here: https://www.flickr.com/photos/oskay/472097903/in/photolist-HHCg2-5t7Dhs-649Tiq-6jWpob-6qAufF-6uRhPY-fPAjmM-7Bsx7p-skWEq-fN26jm-fPSUPj-657L6f-9cm9cZ-fPT5Z7-dDQcHQ-8T5VsR-7y1uao-9gpVUx-fPSRfQ-8hn3Lp-fMLq6z-65tZrh-4kLkhS-nAtHNb-9DBxhM-mJQ4YP-qwEAZU-fN4MHq-fN285Q-fMJRv2-5rLRPx-4vXF16-kdg4y4-fMLoJP-3Vyqee-eB2VEv-cruaPL-fMLxnR-74Jnqm-c7HQFG-bmJRtK-5JSYs1-8Cwdw9-ortPHi-6pgyMc-csDtH7-qKGgn3-dDhwj7-qDpfP1-Cvv87Z