Quiz 6

--Originally published at Loading…

I decided to make Quiz 6 before the Activity 7, because it seemed to me would be simpler, also the quiz is for this week. BUT this quiz was too different that the others, it was more time-consuming  and really tested me.

We had to do the first 5 exercises of this page, and they were a little bit different from what normally we do. I did them in disorder, but here they all are.

Activity 1, run a program.

This one was one of the most difficult, and not precisely because it was too hardcore, more like, it wasn’t running correctly through the fault of a parenthesis in the wrong place.

So, the activity was:

Type in the following program and run it:

#include 
main()
{ /* PROGRAM TO PRINT OUT SPACE RESERVED FOR VARIABLES */
	char c;  
	short s;  
	int i;  
	unsigned int ui;  
	unsigned long int ul; 
	float f;
	double d;  
	long double ld;  
	cout << endl 
  	     << "The storage space for each variable type is:"
	     << endl;
	cout << endl << "char: \t\t\t%d bits",sizeof(c)*8;  //  \t means tab 
	cout << endl << "short: \t\t\t%d bits",sizeof(s)*8;
	cout << endl << "int: \t\t\t%d bits",sizeof(i)*8;
	cout << endl << "unsigned int: \t\t%d bits",sizeof(ui)*8;
	cout << endl << "unsigned long int: \t%d bits",sizeof(ul)*8;
	cout << endl << "float: \t\t\t%d bits",sizeof(f)*8;
	cout << endl << "double: \t\t%d bits",sizeof(d)*8;
	cout << endl << "long double: \t\t%d bits",sizeof(ld)*8;

First I completed what it was needing to the program, added the libraries & , wrote using namespace std; (as always), and wrote int before the main. Then I substituted the cout << endl << for printf(. Later, in order to make sizeof( )*8 works Ken said that we need to wrote int( before. And that’s all, this is my code:

quiz6-1

With this activity I learned to use \t for add

quiz6-2
quiz6-3
quiz6-4
quiz6-5
whatsapp-image-2017-02-14-at-10-54-35-pm
whatsapp-image-2017-02-14-at-10-57-10-pm
Continue reading "Quiz 6"

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

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


Suman y suman y vuelven a sumar ♪♫

--Originally published at Adal´s Blog

La actividad de esta semana es:


La actividad consiste en crear un código el cual nos ayude a sumar un rango de valores dado


Este problema lo resolví con un ciclo un while para así obtener la sumatoria de los números  

Personas de ayuda:
  • Sandoval A.

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