Thursday, March 10, 2016

modulo


What does the modulo (%) operator do, and why is it useful in generating random numbers? Provide a code example and explanation.

It divides two #s and stores the remainder

Wednesday, March 9, 2016

Language


Why do computer programming languages exist? Why do we use them instead of just typing instructions in English? Tie your answer back to the peanut butter and jelly activity today.

We use the computer language because that is how the computer is programmed and to communicate with it we need to use that language.

Monday, March 7, 2016

Compare and contrast


Compare and contrast the difference between return values and parameters in functions. How do they used? How do they work? Are they always needed? Provide and explain a code snippet example.

Function does not return a value.As before this function does not return a value hence it is declared as having type void. It now takes an integer parameter n which indicates the number of lines to be skipped. The parameter list then consists of a type and a name for this formal parameter. Inside the body of the function (enclosed in {}) a loop control variable i is declared. This variable is a local variable to the function. A local variable defined within the body of the function has no meaning, or value, except within the body of the function. It can use an identifier name that is used elsewhere in the program without there being any confusion with that variable. Thus changing the value of the local variable i in the function skip will not affect the value of any other variable i used elsewhere in the program. Similarly changing the value of a variable i used elsewhere in the program will not affect the value of the local variable i in skip.













void skip(int n)
   // Function skips n lines on output
  {
    int i;   // a local variable to this function
      // now loop n times
    for (i = 0; i < n; i++)
      cout << endl;
  }

Friday, February 26, 2016

Loops

What are for loops and when would you decide to use them in code (instead of while loops)? Describe the three parts that make a for loop “run” and how they work.

for-loop is a programming language control statement for specifying iteration, which allows code to be executed repeatedly.The three parts of loop is the start point,end point,and number.They tell you when to start, end and what number to count by.

Thursday, February 25, 2016

Robots taking over


What did you think and feel about the video, Humans Need Not Apply? Do you have any critiques- things the the author didn’t mention or might have gotten wrong? How can society address the concerns he brought up in the video?

I feel open minded about the robots or AI taking the little jobs.Society can think of new ways to receive energy.

Thursday, February 4, 2016

How do conditional statements look like in some of the helper practice programs (code.org, code combat, etc)you’ve used? Compare and contrast how you use them and how they act. Include a screenshot of one in action.

Wednesday, February 3, 2016

Compare and contrast



Compare and contrast if, if-else, and switch statements. What do they have in common and how are they different? When would you use each?
I dont know