#WSQ07 Lists 03/03/17 and WSQ07.cpp

--Originally published at Solving Problems with Programming

PICTURE OF ACTOR

So in this eight week class I started with doing the survey of mid semester where I gave ideas in order to improve this course and this and this WSQ07. I started reviewing in creating and calling functions in C++. #Mastery06, #Mastery07, #Mastery16 Use of recursion for repetitive algorithms, #Mastery17 When to use what type of repetition in a program and #Mastery18 Creation and use of Arrays/ Vectors in C++.

What I did for this numeric program is solving the problem to the user by writing a program that asks the user for 10 numbers  (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.Futhermore, Once you have this working, change it so that users keep giving you values until they signal “no more values”. How would you implement this and in particular for the C++ group, how to you deal with an unknown size to your array during compilation?

The quantity of the value depends of the quantity of the type float variable that has only 32 bits of leght, therefore you need a new library in order to increase the value of numbers called Biginteger.hh but I am going to add it in the next WSQ08 called Yo soy 196. Next, to deal with an unknown size of my array during compilation we need to ask the user the number of that size and save it in a variable n.

The resources I need it to solve this program are here:

ken bauer

Similar code made by Eduardo Torres

C Programming Tutorial: Functions (Call By Value, Reference,passing Arrays to function)

The following photograph shows the solution to this problem:

wsq7v2

wsq7v3

wsq7v4wsq7v5

wsq7v6

Picture of author

So at first I wrote the same structure of the program just did the same as

s1
s2
s3
s4
s5
Continue reading "#WSQ07 Lists 03/03/17 and WSQ07.cpp"

Quiz 04

--Originally published at prgrm.co

In this week’s quiz, the goal was to ask the user for three different numbers and then make two functions. The first function was to display the lowest of the three numbers, and the second one was to add the squares of the three numbers.

In order to accomplish this, I needed to include three different libraries.

  • iostream
  • cmath
  • algorithm

Then the making of the functions, the first one which is to find the lowest number looks like this:

int min3(int x, int y, int z){
 return min(min(x, y), z);
 }

Notice the way the “return min(min(x , y), z)” is written, this is due the fact that the “min” function works only for two integers, so by repeating the “min” function first it chooses between “x” & “y” and then between the result from this later & “z”.

The second function is to add the squares of the three numbers, this one is relatively easier as the only thing you need to do is multiply and add, like so:

int sumofsquares(int x, int y, int z){
 return ((x*x) + (y*y) + (z*z));
 }

Here’s the full code:

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int min3(int x, int y, int z){
 return min(min(x, y), z);
 }

int sumofsquares(int x, int y, int z){
 return ((x*x) + (y*y) + (z*z));
 }

int main(){

 int no1, no2, no3;

 cout << "This program will give you the lowest number and the sum of squares of the three numbers asked." << endl;
 cout << "First: ";
 cin >> no1;
 cout <<"Second: ";
 cin >> no2;
 cout << "Third: ";
 cin >> no3;

 cout << "The smallest of the three numbers is " << min3(no1, no2, no3) << " ,the sum of the squares is " << sumofsquares(no1, no2, no3) << 
Continue reading "Quiz 04"

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"

Yo por Yo, por Yo, por Yo…

--Originally published at Adal´s Blog

La actividad esta así:


Básicamente consiste en hacer un programa que nos permita calcular el factorial de cualquier número que le introduzcamos, es decir que hay que multiplicar todos los números enteros positivos que hay entre ese número y el 1.  

En el libro de la clase thinkCScpp, viene un ejemplo, el cual solamente lo voy a adaptar al código


Libro de ayuda:
  • thinkCScpp

A reformular!

--Originally published at Adal´s Blog

Y el tema de hoy es el siguente: 


Gracias a que esta actividad ya estaba hecha solo fue necesario hacer las funciones y andarlas llamar despues, gracias a que los valores se van sustituyendo cada ves que se llama de nuevo la función, solo utilice 3 variales, dandole mas volativilidad a la Z  


Pagina de ayuda:

Factorial Calculator

--Originally published at Loading…

This one was a little harder than the others, and it was a challenge to begin with because I couldn’t remember what is a factorial. But after I asked Ken and he explained me ( )…ie_factorial__6…the activity, it wasn’t too difficult. The activity consist in this:

Create a program that asks the user for a non-negative integer (let’s call that number n) and display for them the value of n! (n factorial).

After showing them the answer, ask them if they would like to try another number (with a simple y/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered n).

So, the first thing was do a function for the factorial, I established this function with the loop for, I wasn’t too sure of how doing it, so with the help of one page of Google and a classmate’s blog I could do it . In my main I established my variables as int and char, and then add the loop do/while for repeat until the user said no. Inside the “do” I put an if for the case that the number should be negative. This is my code:

factorial01factorial02

And this is how it works ?:

factorial03


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


Me llaman me llaman me llaman ♪♫ (Jammin Bob Marley)

--Originally published at Adal´s Blog

En la clase de hoy tuvimos un quiz el cual dice:


En pocas palabras, lo que tenemos que hacer es una función que nos diga cual es el numero menor de una lista de tres números, y con estos mismos saber la suma de sus cuadrados.

En términos simples, una función es un pedazo de código que nos retorna un o mas valores específicos esto con el fin de ayudarnos a no escribir lineas de código una y otra vez