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

 

 

#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/

 

Fun with Numbers #WSQ03

Task today was to ask for 2 integer numbers in order to do various mathematical operations.

  • The difference of the two numbers.
  • The product of the two numbers.
  • The integer based division of the two numbers (so no decimal point). First divided by second.
  • The remainder of integer division of the two numbers.
  • And as a bonus, addition.

First ask for the numbers:

Screenshot4.1

Second, write the commands the program will run:

Screenshot4.2

Third, thing to do is to compile your program.

Screenshot4.3.png

Next, you must run it

Screenshot4.4

And there you have it… Really simple program, but I had help from my friend Christian, because he knows more than me 😀

 

5397869877_ce1fd0e087_z
.numbers by: .Thomas Alexander https://www.flickr.com/photos/thomasspeller/5397869877/in/photolist-9dZuE2-fcVveb-dJQF46-ipz26T-y9DdY-wiAw81-5NnYx5-fQ6qDt-6UtG9S-kD9Lqt-Cas4r9-466Ys3-7gpM2X-5pmhD5-6px3YT-7r4UdN-bFwnMH-4CzFUi-6pBcjh-jXBuPc-9rLSJU-eiMSjS-51NuHQ-9UAzzu-AzrwCH-aYjhbM-orXCLa-6mCuiz-kaLZFH-5Y6Zhn-eZ8wJY-7H8vPq-3KxvG-r4m9Jk-5peSdV-4Ne9WF-65W2Xp-jr9JBi-p8ZxD6-kAtk2a-c8agC-9A4eFW-uuRGf7-9fdyfV-4umSgE-9djrNk-fwQwZH-uAVhM-3ZwQB4-4hkQiy

 

“Hello World” #WSQ02

After watching Ken’s video on youtube “LINK” about Hello World on C++

Screenshot1.2.png

I decided to work with my program following his directions, once I did this, it didn’t work for about a day, after this happened I came to school hopping for the best; special thanks to Christian Moreno for helping me out, he told me to download cygwin again and install many components I didn’t have. He said: “Descargalo otra vez, y si no checo tu programa” well the program was correct but the components weren’t.Screenshot2.2

This was the code for Hello World, Christian continued coaching me while we tried to make it work, succesfully he told me that I had compiled correctly; in order to compile you must write “g++” and the name of your program , and that in order to make it work you should always put “./a.exe” in order to execute the program compiled before.Screenshot3.2.png

Finally, after re-downloading cygwin, I was able to run this easy program… Hello World

 

Banana for scale!!

7101134513_5295b936e7_z
JK Brickworks https://www.flickr.com/photos/truedimensions/7101134513/in/photolist-bPvaTF-815sgJ-fap44G-2FJ1Ew-3KpTqJ-nv1Lnt-LkVum-5355XZ-7Y55Te-e5bou-bMW2de-agXchY-byVobx-6UfMT4-fooheV-8zj7hR-ef2zD-qQThR-PA4QL-4TEBQT-irrsTZ-2HUWVX-fzf7gt-5mnJQe-3q89kQ-gEYy44-hja1S-fFiUGo-79jGxr-4EZf6b-7mmnCa-pS5bBo-7w5Bhs-r7AbEi-56GEvw-bziV3g-9p29pc-npX8AN-r5jjNd-gWTn9R-oQnkxj-4dvFCC-5M1hvH-8z3ZBT-3JEzQQ-9JDW8Z-jpgBVS-nnuudg-9iDSQS-8VWDEW

 

 

#WSQ01 Get Coding

First, I decided to get the platform for coding, for this I asked MR. Ken, he suggested Cygwin, he showed us on this video how to get it done. Link

After it was completed, this icon appeared on the desktop

 

Screenshot1

Then I moved on to get the editor. First I tried with Atom, but the installer wouldn’t work on my pc, therefore I move on to Ken’s suggestion for Windows “Notepad++” where the page suggests you which one to get in order to fit your necessity.

Screenshot2.png

After installation is completed this icon would appear on your desktop if you decide to include it during installation.

Screenshot3.png

Once you open both, this is how it should be seen.

Screenshot4.png

And there you have it done…

 

Penny Board because yes 😀

7968429654_906f3ae569_z
PennyBoard picture by: Paul Chery https://www.flickr.com/photos/paulchery/7968429654/