Quiz#3 Part#2

For this second part of the Quiz, we had to do the Fibonacci sequence, where the user gives a number and the Fibonacci sequence will end on the users number. At first I intended to use a Do, While function where we had two counters, one initialized in 0 and another in 1, and each time the loop repeated the counters will add 1 until it reached the number the user placed in.

But after some trying, it didn’t worked, so I called Christian to ask him for help, he told me he hadn’t used any do, or while, and showed me how to do it that way, this time I tryed as he told me and it did work, so I left it how he told me.

My base function was something like this:

int Fib (int cont1, int cont2, int x) {

int x, int cont1==0, int cont2==1

do{

Fib= (cont1+cont2)

while (cont2==x)

 

Something like that, but it didn’t work, so I changed it to this one. Found HERE

Screenshot12.2

And the process in Cygwin, in which I wanted to know until what number the programm would work without any trouble. I found out that in 50, the numbers came out negative, and by number 300, the computer has not given me an answer yet.

Screenshot12.1.png

 

 

Quiz #3 Part#1

I had some help from Here, and from the blogpost of some of my classmates, but anyways, this first part was kind of a problem for me because of this…

Screenshot11.1.png which actually continues going down, but anyways I couldn’t understand what was wrong with this, until I discovered that I had declared a variable like 3 times. Now this is how the program should look.

Screenshot11.2.png

Once you get to understand what the program does, it’s not so easy to write it, but the best way to do it is by writting a function for the process, before starting the main program.

Here is the function I used, but the full coding is HERE

float distance (float x1, float  x2, float  y1, float  y2) {
float dis;
dis=sqrt((x2-x1)*(x2-x1)+((y2-y1)*(y2-y1)));
return dis;
}

After declaring the variable (dis) = distance we can ask the user for values for (x1,x2,y1,y2) and writing the formula, in order to get the value “dis=distance(x1,x2,y1,y2);”

Screenshot11.3.png

First I thought of using “int”, but after looking at someone elses job, I decided to use “float”, even though I think you can also use “double”. I also saw that you can ask for two variables at once by writting (cout<<“…”<<endl; cin>>x>>y).

 

 

 

#WSQ04 Flipped Learning

WHAT DO WE THINK ABOUT FLIPPED LEARNING, and Ken’s way to evaluate?

 

Well to begin I would like to say that Lecturing in front of a class can be boring for both the students and the teacher, and the outcome is sleeping students and no learning at all, the way teacher try to teach us is unreliable at this time, because most students would rather work on their own instead of hearing to the teacher for 1:15 hours, that is the main problem with having a lecturing class, instead what the flipped learning is asking for the students to help themselves to learn, by working in teams or asking everyone in order classrooms whether they know or not, students may also ask for help of the teacher, but always remembering that the main teachers are ourselves.

high

Another thing to talk about is the way Ken evaluates his students, to me this is the perfect way, because we show ourselves what we are capable of, and in case we couldn’t do it, it is ok because we have our fellow classmates and friends who might help us easily. By abolishing grades, we don’t have the pressure to know that we need to study everything a night before to “pass” the parcial. WE JUST SHOW WHAT WE CAN DO, AND WHAT WE KNOW!!!

bat

If you want to make your own Memes, come here

 

Quiz#2 Part#2

Part 2 was kind of a problem because I had it already but it kept telling me I was incorrect, but I couldn’t figure out the problem, so I called the assistance of Batmantec, and we checked it together for around 20 minutes; finally we discovered that the real problem was that instead of using “>>” in cin… I had “<<” so we weren’t able to do anything while we corrected that, the way we figured out, was by checking both his program and mine at the same time, line by line in order to figure the problem; So thank you Batmantec…

 

Now this time the task was to creat a function where depending on the number the user inserted, the number of * that would appear was the number inserted before, as if the user wrote 3, that would lead into ***  Here is the code, in case you would need it.

Screenshot10.1.png

Before you can write the program, you must write the function for the “stars” which must include a (count = 0), then it must have a do{ which needs to include a cout “*” and which would include (count++) showing that this would add 1 each time the cycle starts again while the (number!=a) is different than the variable; then you end the cycle and save it as stars variable.

 

Then you write the main program, which will ask the user for a number, and place it invariable (a) and then use the “stars” function to display the number of stars = to the number in the variable asked before.

And this is how it would show on the Cygwin

Screenshot10.2

Special Thanks to Batmantec, for helping me solve the problem which didn’t let me work.

Quiz 2 part 1

  1. Create a program with the following function.

Write a function called superpower that has recieves two parameters (ints) and returns an integer which is firs parameter raised to the power of the second, which is to say it returns (a**b).

There are many ways to do this, but the intent is for you to use a loop or recursion.

Here is my code, in case you might need it.

I had help from “BatmanTec”

But here is how you should do it.

Start by creating the functions you will be using: “superpower”, for this you want to declare two variables “a,b”

Later on declare 3 more variables, this will be the counter (count) , in this case (x=a) and (s, would be saving the data),  (count++, meaning that each time theres a loop count will add 1 to the count), the loop will continue to add 1 until (count!=b) then it will stop and give you the answer.

Screenshot9.1.png

Then you have to define what the variables defined in the past, just by writing “int x,a,b,cout, s;

and ask for the numbers, the one you want to raise and the one you will be raising by, finally add the function known as “superpower” and show the answer

Screenshot9.2.png

Well then you must compile it on Cygwin, and check if it works

Screenshot9.3.png

And there you have it !

 

 

#WSQ09 Factorial Calculator

In case you might need it, here is the code

And I used this web page to help me out: http://fahad-cprogramming.blogspot.mx/2013/02/program-to-find-factorial-in-C-Programming.html

 

Well now to begin with this awsome factorial calculator we shall start as we had before

#include<iostream>

using namespace std;

Then we show that the numbers we will be using are “int” for num, factorial, else we could use “float” but “int” is the one we choose for this program.

So we ask for the number we will be getting the factorial

Screenshot8.1

Then we proceed to show what “a” would be in order to make this factorial calculator work a=1;a<=num;a++ sayin that a would be 1 until it’s lower or equal to the number you introduce at the beginning, and saying that a would increase 1 each time until it’s equal to your first number

In order to get the factorial the formula we would be using is ” factorial=factorial*a;  ” showing that the factorial will multiply “a” in order to get the right factorial number.

Screenshot8.2.png

Finally you will be giving out the result of the factorial of the number the user wrote in, and never forget ” return 0; ” otherwise your program might not work.

 

 

#WSQ08 Functions Beach

Hey so for this new assigment we had to do Fun With Numbers again, but this time we needed to create a function before we asked the user for the numbers; therefore the structureyou must follow is:

int add (int a, int b)
{
    int s;
    s=a+b;
    return s;
}

That’s the main structure for each function, you must do this for the substraction, division, and integer division, remember to change the letter or name for each function though.

Screenshot7.1.png

Then you can proceed to begin with the main program, where you’d be asking for the numbers who will be used  :

int main ()
{
int a, b, s, r, m, d, i;
cout<< “Give me a integer number” << endl;
cin>>a;
cout<< “Give me second integer number” << endl;
cin>>b;

Screenshot7.2.png

There you can see that we choose our functions created before, and showing that the integers which are going to be use are the ones choosen before; finally we print the answers using “cout” finally ending with the return 0; “

Heres is my code, in case you need it

 

 

Quiz!

Well we had to do a quiz.

Here is the quiz

So I decided to do it by hand, because I thought it would be easier and faster, here goes first program, the problem you had to do was simply calculating the Volume of a cylinder, using the formula. I used ( Pi*(radius*radius)*height)or(3.1416*(radius*radius)*height) or you can use Pi=3.1416, which I think would the best way to do it.

1st and 2nd lines: insert a radius and a height.

Remember to use int to define radius,  height

3rd : add the formula for Volume.

4th: print the result of the formula.

IMG_6566

Next program was a simple calculator who would multiply two numbers that the user would choose, then the division without remainder,  and finally you would get the remainder of the division.

1st & 2nd : ask the user for two numbers, num1 & num2

Remember to use int to define num1, num2

3rd, 4th & 5th : write what the result of each operation will be (num1*num2)(num1/num2) (num1%num2)

IMG_6567

 

Finally we should repeat the 2nd program but this time using “float” instead of “int” and do the addition,  substraction, multiplication, and division of two numbers.

1st & 2nd : ask the user for two numbers, num1 & num2

Remember to use float instead of int to define num1, num2

3rd, 4th, 5th & 6th : write what the result of each operation will be (num1*num2)(num1+num2)(num1-num2)(num1/num2) (num1%num2)

IMG_6568.JPG

That was basically the quiz we had to do in order to prove ourselfes of how much we were capable of doing on our own.

 

 

 

#WSQ05 Random Numbers

Hello Class today we’ll be looking at generating random numbers, but not actually to generate them but, you must try to guess them…

I didn’t knew how to do this, but thanks to Batmantec I realized how to do it, and why it was this way; anyways here is the code in case you might need it.

Take a look of how it should look when you are done.

Screenshot6.1.png

On the other hand, here is a picture of the code… It’s actually “originality”

Screenshot6.2

 

 

Now here it’s a picture of Manzanillo

DCIM100GOPRO
Manzanillo upside down: By Miguel Jiménez https://www.flickr.com/photos/139404735@N04/24630233695/in/dateposted-public/

 

 

 

#WSQ05 -Temperature

In order to complete this new task you must follow next steps.

1st Open Notepad++ Screenshot5.1

2nd Start working on your code, and use the formula given by Mr. Ken

Screenshot5.2

3rd Always keep on checking wether your code works or doesn’t. I did it many times until someone told me it wasn’t .a/. but ./a.

Screenshot5.3.png

If you need to check your code… Here is mine

 

4298911131_ffbae9b3bd_z
Rachel Johnson: I program in my sleep https://www.flickr.com/photos/rachel-johnson/4298911131/sizes/z/