Functions??? Againnnnn???

--Originally published at Tec Life

Wellllll…. Again pffff.

The problem was this:

You will go back and do WSQ01 – Fun with Numbers again.

But this time, write a function for each calculation. Each function should define two parameters (in this example of type int) and return the correct value as an integer as well.

You main program needs to ask the user for the input and then call each function to calculate the answer for each of the parts.

So I use my older program and I start work in there, the only different thing that I do is that in this program I am going to use functions.

So I do thissssss, I give name to my function, then I put the values as int that are going to be on my functions, then I give value to my function and then return my function and the other functions was easy tooooo, the only thing that I do was change the operation of my function for what I suppose to need. And I do everything in one program why not?

Like this:captura-de-pantalla-2017-02-27-a-las-11-07-59

Image from: http://mathematicaled107.blogspot.mx

 


Post of the week #5 what things I learned in this week #5 ? And Index of Mastery Topics

--Originally published at Solving Problems with Programming

Picture of author

First let me tell you that  I learn and achieved all transversal topics and you can see it in the following link: Post of the week #3 what things i learned in this week #3 ? And Index of Mastery Topics

I also explain my project and formed a small team that corresponds of completing this ability to create C++ project in IDE and run inside the IDE and can be explained in my post My Project For the Course TC1017 and Expo Ing

Futhermore, I am going to present the report of all the Mastery Topics achieved in this week:

  1. #Mastery01 Use of comments, achieved in: Post of the week #2 what things i learned in this week #2 ?
  2. #Mastery02 C++ Good Style coding conventions, achieved in: Post of the week #2 what things i learned in this week #2 ?
  3. #Mastery03 Basic types and their use, achieved in: Post of the week #2 what things i learned in this week #2 ?
  4. #Mastery04 Basic output (print), achieved in: Post of the week #2 what things i learned in this week #2 ?
  5. #Mastery05 Basic user input (text based), achieved in: Post of the week #2 what things i learned in this week #2 ?
  6. #Mastery06 Calling functions, achieved in: #Quiz03
  7. #Mastery07 Creating functions, achieved in: #Quiz03
  8. #Mastery08 Importing and using libraries, achieved in: Post of the week #1 what things i learned in this week #1 ?
  9. #Mastery09 Creating and using your own libraries (program with multiple files), achieved in: #Quiz03
  10. #Mastery10 Use of the conditional “if”, achieved in: #WSQ02 Post Temperature 23/01/17 and WSQ02.cpp
  11. #Mastery11 Use of “else” with a conditional if, achieved in: #WSQ02 Post Temperature 23/01/17 and WSQ02.cpp
  12. #Mastery12 Nesting of conditional statements (ifs inside ifs): #WSQ02 Post Temperature 23/01/17 and WSQ02.cpp
  13. #Mastery13 Use of
    recursion
    int-sumsquare
    double-function
    Continue reading "Post of the week #5 what things I learned in this week #5 ? And Index of Mastery Topics"

Post of the week #4 what things I learned in this week #4 ? And Index of Mastery Topics

--Originally published at Solving Problems with Programming

Picture of author

First let me tell you that  I learn and achieved all transversal topics and you can see it in the following link: Post of the week #3 what things i learned in this week #3 ? And Index of Mastery Topics

I also explain my project and formed a small team that corresponds of completing this ability to create C++ project in IDE and run inside the IDE and can be explained in my post My Project For the Course TC1017 and Expo Ing

Futhermore, I am going to present the report of all the Mastery Topics achieved in this week:

  1. #Mastery01 Use of comments, achieved in: Post of the week #2 what things i learned in this week #2 ?
  2. #Mastery02 C++ Good Style coding conventions, achieved in: Post of the week #2 what things i learned in this week #2 ?
  3. #Mastery03 Basic types and their use, achieved in: Post of the week #2 what things i learned in this week #2 ?
  4. #Mastery04 Basic output (print), achieved in: Post of the week #2 what things i learned in this week #2 ?
  5. #Mastery05 Basic user input (text based), achieved in: Post of the week #2 what things i learned in this week #2 ?
  6. #Mastery06 Calling functions, achieved in: #Quiz03
  7. #Mastery07 Creating functions, achieved in: #Quiz03
  8. #Mastery08 Importing and using libraries, achieved in: Post of the week #1 what things i learned in this week #1 ?
  9. #Mastery09 Creating and using your own libraries (program with multiple files), achieved in: #Quiz03
  10. #Mastery10 Use of the conditional “if”, achieved in: #WSQ02 Post Temperature 23/01/17 and WSQ02.cpp
  11. #Mastery11 Use of “else” with a conditional if, achieved in: #WSQ02 Post Temperature 23/01/17 and WSQ02.cpp
  12. #Mastery12 Nesting of conditional statements (ifs inside ifs): #WSQ02 Post Temperature 23/01/17 and WSQ02.cpp
  13. #Mastery13 Use of
    recursion
    int-sumsquare
    double-function
    Continue reading "Post of the week #4 what things I learned in this week #4 ? And Index of Mastery Topics"

Post of the week #3 what things i learned in this week #3 ? And Index of Mastery Topics

--Originally published at Solving Problems with Programming

Picture of author

First let me tell you that in my last post i learn all transversal topics that are:

  • Ability to create C++ file and run from command line (terminal)
  • Create accounts: Blog, Twitter, GitHub
  • Submit work via Blog RSS and GitHub
  • Demonstrate use of Linux sufficient for quizzes/exams
  • Install Linux on their own computer

And you can find it in these posts:

Post of the week #2 what things i learned in this week #2 ?

Post of the week #1 what things i learned in this week #1 ?

I also explain my project and formed a small team that corresponds of completing this ability to create C++ project in IDE and run inside the IDE and can be explained in my post My Project For the Course TC1017 and Expo Ing

Futhermore, I am going to present the report of all the Mastery Topics achieved in this week:

  1. #Mastery01 Use of comments, achieved in: Post of the week #2 what things i learned in this week #2 ?
  2. #Mastery02 C++ Good Style coding conventions, achieved in: Post of the week #2 what things i learned in this week #2 ?
  3. #Mastery03 Basic types and their use, achieved in: Post of the week #2 what things i learned in this week #2 ?
  4. #Mastery04 Basic output (print), achieved in: Post of the week #2 what things i learned in this week #2 ?
  5. #Mastery05 Basic user input (text based), achieved in: Post of the week #2 what things i learned in this week #2 ?
  6. #Mastery06 Calling functions, achieved in: #Quiz03
  7. #Mastery07 Creating functions, achieved in: #Quiz03
  8. #Mastery08 Importing and using libraries, achieved in: Post of the week #1 what things i learned in this week #1 ?
  9. #Mastery09 Creating and using your own libraries (program with multiple files), achieved in: #Quiz03
  10. #Mastery10 Use of
    Continue reading "Post of the week #3 what things i learned in this week #3 ? And Index of Mastery Topics"

Quiz #4

--Originally published at Programming 101

Today we had our fourth quiz and I found it quite hard. I thought about the problem and understood it but I had a bit of trouble writing it. In the end, a friend in class helped me and I got a better idea of what to do.

Functions were a bit of a headache for me but I’ll read more pages of the book and keep on working with my friends.

Here’s a screenshot of the program and three examples to show how it works.

Cheers!

captura-de-pantalla-12


Quiz 4

--Originally published at Tec Life

For this quiz we have to do this:

For this quiz I want you to (in class) create a program with two functions:

  • int minimumThree(int x, int y, int z){ }  // returns the value that is smallest of x, y and z
  • int sumSquares(int x, int y, int z) {}  // returns the value of the sum of squares of x, y, z

You should make a main routine that asks the user for three numbers and then calls your functions to which should *RETURN* the value and you print in the main program.

So I started writing my program normally, declaring my variables, naming my functions and to make the user to write the three numbers.

captura-de-pantalla-2017-02-02-a-las-09-28-40

Then I make what my functions would do, that says in the first function that I am going to multiplied my variables with the function “pow” and in a parenthesis my variable “,” and the number I want to multiplied my variable, in this case 2 for square and the sum the operations.

And on my second function I put conditions with if and else to make the program know what number is bigger than the other and finally printed on the result.

captura-de-pantalla-2017-02-02-a-las-09-28-52Image from: http://www.quizfactor.com/quiz/general-knowledge/5

#Quiz04


Sum of Numbers

--Originally published at Tec Life

This was the problem:

Write a program that asks for a range of integers and then prints the sum of the numbers in that range (inclusive).

You can use a formula to calculate this of course but what we want you to do here is practice using a loop to do repetitive work.

For example, the sum from 6 to 10 would be 0 + 6 + 7 + 8 + 9 + 10.

I start declaring normally my variables as integers and one different that I give him a value “suma= 0” later I will explain that, and one variable as character “con”.

I start my main asking the user t put the ranges of the sum and then I put and if in case if the range one was lower than the range two.

Then I put a loop with a loop while that says that the result is going to be equal to the result plus one while range one be lower than range two and every time that the operations happens range one is going to be one number more that it was until be the same as range two, and finally put the result of the sum.

captura-de-pantalla-2017-01-23-a-las-09-09-43

#WSQ04

Image from: http://www.clipartbro.com/categories/greek-symbol-for-sum-clipart


Pick a Number

--Originally published at Tec Life

This was the problem:

Write a program that picks a random integer in the range of 1 to 100.

There are different ways to make that happen, you choose which one works best for you.

It then prompts the user for a guess of the value, with hints of ’too high’ or ’too low’ from the program.

I start adding the libraries that I search on internet “stdlib.h” and “time.h” to make the program to generate one random number, then I declare my variables as local variables because there are going to change and I start coding the thing that I need to make the program give me a random number, that says that is going to generate one random number between 1 and 100.

Then I make a loop in case if I don’t guess the random number that the program makes, and I put if the number I put randomly in order to guess the other number was less that it was the program is going to say me that the number insert was to low, and one in case it would be to high.

And if I guess it the program is going to say me congratulations :).

captura-de-pantalla-2017-01-23-a-las-09-31-34

#WSQ03


Temperature

--Originally published at Tec Life

This was the problem:

Write a program that will prompt the user for a temperature in Fahrenheit and then convert it to Celsius. You may recall that the formula is C = 5 ∗ (F − 32)/9.

Modify the program to state whether or not water would boil at the temperature given.

So I start coding normally “Declaring variables, including libraries, and in the main put the text that I will need in the problem”.

After asking the user the Fahrenheit degrees, I give value to the celsius degrees with this formula: C = 5 ∗ (F − 32)/9, and that was all in order to convert Fahrenheit to celsius, then I put my condition  in case if the result is bigger than 100. I start my condition with an “If” and next to it the conditions and I put what would happen, and then I put and else in case that this condition were not true.

captura-de-pantalla-2017-01-23-a-las-08-39-12

 

#WSQ02

Image from: http://climateresources.net


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.

 

captura-de-pantalla-10

captura-de-pantalla-9