#WSQ05 Six Tutorial On To Functions 12/02/17 and WSQ05.cpp

--Originally published at Solving Problems with Programming

Picture of author

So in this sixth week class I started with doing the #Quiz06 and this WSQ05. Therefore, I started reviewing in creating and calling functions in C++. #Mastery06 AND #Mastery07

What I did for this numeric program is solving the problem to the user by writing a program that asks for the same thing of WSQ01 #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp. Nevertheless, I am writing a function for each calculation. Each function defines two parameters (in this example of type int and float) and return the correct value as an integer as well.

The main program asks the user for the input and then calls each function to calculate the answer for each of the parts.

Remember that in this program needs to have the other points that the post of #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp has:

Solving the problem to the user by asking the user for two integer or float values, then use those two values to calculate and show the following:

  • The sum for the two numbers
  • 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 resources I need it to solve this program are here:

Similar code made by Eduardo Torres B

The following photograph shows the solution to this problem:

aaaaa

Picture of author

So at first I wrote the same structure of the program just did the same as what i did in Hello World: Second Class, Second Blog (Blog of the second class 12/01/17) and Hello World.cpp,  #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp#WSQ02 Post Temperature 23/01/17 and WSQ02.cpp#WSQ03 Post Pick a Number 23/01/17 and WSQ03.cpp

wsq5v1
wsq5v2
wsq5v3
wsq5v4
wsq5v5
wsq5v6
aaaaaaaaaa
Continue reading "#WSQ05 Six Tutorial On To Functions 12/02/17 and WSQ05.cpp"

#Quiz06

--Originally published at Solving Problems with Programming

PICTURE OF AUTOR

THIS IS THE #QUIZ6 (WEEK 6) WHOSE OBJECTIVE IS PRACTICE THE CODES THAT ARE MADE IN C++. COVERING #MASTERYTOPIC03

This #QUIZ06 are 5 exercises to help me practice my skills. At present, I’m considering the following as projects: 1,2,3,4,5. These are designed to stretch me gently.

At doing this quiz I learnt that the language C++ keeps changing and runs different on different machines. For the first question I had to use the old command printf instead of cout to format the printing and I had to research the reference in this page: Reference for exercise 1 with also including the old library include <stdio.h>

  1. Exercise 1 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;
    }

Pictures of the quiz6 exercise 1.:

primera

LINK IN GITHUB:Exercise 1 in Github.cpp

Also is in here:

#include <iostream>
#include <cstdlib>
#include <stdio.h>
using namespace std;


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:"
<< 
segunda
tercera
cuarta
exercise3
octava
quiz6v4
quiz6v4444
decima
decima2
quiz6v5
Continue reading "#Quiz06"

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"

#Quiz04

--Originally published at Solving Problems with Programming

PICTURE OF AUTOR

THIS IS THE #QUIZ4 WHOSE OBJECTIVE IS CREATE AND CALL FUNCTIONS TO DO DIFFERENT TASKS AT DIFFERENT TIMES. COVERING #MASTERYTOPIC06 #MASTERYTOPIC07 .

This #QUIZ04 makes a main routine that asks the user for three numbers and then calls the functions to return the value that is smallest of x, y and z and returns the value of the sum of squares of x, y, z  which should *RETURN* the value and prints it in the main program.(#Mastery11).

Pictures of the quiz:

quiz4v1

quiz4v2

quiz4v3

FIRST TO DO THIS #QUIZ04 I HAVE TO DECLARATE A GLOBAL VARIABLE AND THE NEXT THING YOU DO THE SAME AS OTHER PREVIEW CODES DECLARATE YOUR TYPE OF VARIABLE AND YOUR VARIABLE AND ASK THE USER TO GIVE YOU THE 3 NUMBERS

AFTER THAT YOU HAVE TO CALL YOUR CREATED FUNCTIONS THAT WERE:

  • 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 HAVE TO KNOW THAT USING THESE 2 FUNCTIONS IS OTHER EXTERNAL FUNCTIONS FROM THE MAIN THAT HAS A INT FUNCTION VALUE OF 16 BITS AND DECLARING INT VARIABLES X,Y,Z INSTEAD OF USING THE VOID MAIN THAT HAS 0 BITS OR DOUBLE OF 32 BITS.

TO CALL THE FUNCTION IN THE MAIN YOU USE x= minimumThree (x,y,z);//CALL THE FUNCTION OF THE MINIUM VALUE OF THE NUMBERS AND y = sumSquares(x,y,z); //CALL THE FUNCTION OF THE SUM OF THE NUMBERS AND AT THE BEGINNING OF THE PAGE, YOU HAVE TO DECLARATE AGAIN THE INT VARIABLES OF X,Y,Z BECAUSE THE INT MAIN DOES NOT KNOW AT FIRST WHAT X,Y,Z STAND FOR AND WITH THOSE COMMANDS IT TELLS THE INT MAIN THAT IS IT CALLED.

Like i said before, you must

Continue reading "#Quiz04"

#Quiz04

--Originally published at Solving Problems with Programming

PICTURE OF AUTOR

THIS IS THE #QUIZ4 WHOSE OBJECTIVE IS CREATE AND CALL FUNCTIONS TO DO DIFFERENT TASKS AT DIFFERENT TIMES. COVERING #MASTERYTOPIC06 #MASTERYTOPIC07 .

This #QUIZ04 makes a main routine that asks the user for three numbers and then calls the functions to return the value that is smallest of x, y and z and returns the value of the sum of squares of x, y, z  which should *RETURN* the value and prints it in the main program.(#Mastery11).

Pictures of the quiz:

quiz4v1

quiz4v2

quiz4v3

FIRST TO DO THIS #QUIZ04 I HAVE TO DECLARATE A GLOBAL VARIABLE AND THE NEXT THING YOU DO THE SAME AS OTHER PREVIEW CODES DECLARATE YOUR TYPE OF VARIABLE AND YOUR VARIABLE AND ASK THE USER TO GIVE YOU THE 3 NUMBERS

AFTER THAT YOU HAVE TO CALL YOUR CREATED FUNCTIONS THAT WERE:

  • 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 HAVE TO KNOW THAT USING THESE 2 FUNCTIONS IS OTHER EXTERNAL FUNCTIONS FROM THE MAIN THAT HAS A INT FUNCTION VALUE OF 16 BITS AND DECLARING INT VARIABLES X,Y,Z INSTEAD OF USING THE VOID MAIN THAT HAS 0 BITS OR DOUBLE OF 32 BITS.

TO CALL THE FUNCTION IN THE MAIN YOU USE x= minimumThree (x,y,z);//CALL THE FUNCTION OF THE MINIUM VALUE OF THE NUMBERS AND y = sumSquares(x,y,z); //CALL THE FUNCTION OF THE SUM OF THE NUMBERS AND AT THE BEGINNING OF THE PAGE, YOU HAVE TO DECLARATE AGAIN THE INT VARIABLES OF X,Y,Z BECAUSE THE INT MAIN DOES NOT KNOW AT FIRST WHAT X,Y,Z STAND FOR AND WITH THOSE COMMANDS IT TELLS THE INT MAIN THAT IS IT CALLED.

Like i said before, you must

Continue reading "#Quiz04"

#WSQ04 Post Sum of Numbers 23/01/17 and WSQ04.cpp

--Originally published at Solving Problems with Programming

Link of the picture

So in this seventh class that I had on last Monday I started how to make a program with loops in C++.#Mastery14

What I did for this numeric program is solving the problem to the user by writing a program that asks for a range of integers and then prints the sum of the numbers in that range (inclusive).

I could use a formula to calcute this but what I want 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.

Notice our sum starts with zero, why?. Because it completes the property of sums that are:

{\displaystyle m>n\;,\quad \sum _{i=m}^{n}a_{i}=0}

I talked this part in my video tutorial: #WSQ04 Fifth Tutorial SUM OF NUMBERS 23/01/17

The number of the lower limit 6 is greater than the numbers from 0 to 5, so that is why the result of the sum is zero.

And when we add each number in the range provided by the user. The mathematical formula to do this calculation is?:

sum

sum2

Pictures of author

After that I change my program to handle the user giving the upper and lower bound in the wrong order with error message.

The resources I need it to solve it are here:

sum link 1

sum link 2

The following photograph shows the solution to this problem:

sum3

Picture of author

So at first I wrote the same structure of the program just did the same as what i did in Hello World: Second Class, Second Blog (Blog of the second class 12/01/17) and Hello World.cpp,  #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp#WSQ02 Post Temperature 23/01/17 and WSQ02.cpp and #WSQ03 Post Pick a Number 23/01/17

forloopoverview
1
2
3
4
Continue reading "#WSQ04 Post Sum of Numbers 23/01/17 and WSQ04.cpp"

#WSQ03 Post Pick a Number 23/01/17 and WSQ03.cpp

--Originally published at Solving Problems with Programming

Link of the picture: Link of the picture

So in this sixth class that I had on last Monday I started how to make a program with loops in C++.#Mastery13

What I did for this numeric program is solving the problem to the user by writing a program that picks a random integer in the range of 1 to 100.

There are different ways to make that happen , I chose one method that best works for me.

After that, inside  the program prompts the user for a guess of the value, with hints of ‘too high’ or ‘too low’ from the program.

The program continues to run until the user guesses the integer. I did something extra here including telling the user how many guesses the user had to make to get the right answer.

I checked that my program doesn’t always use the same random number chosen by splitting my problem solving into parts.

At first I only generated the random number and printed that as a first step.

 

The following photograph shows the solution to this problem:

wsq3

Picture of the author.

So at first I wrote the same structure of the program just did the same as what i did in Hello World: Second Class, Second Blog (Blog of the second class 12/01/17) and Hello World.cpp,  #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp and #WSQ02 Post Temperature 23/01/17 and WSQ02.cpp where i explained the application of the #MasteryTopic01 that it is for comments that could be very useful when debugging and #MasteryTopic04 that is basic output for data. Also I did some other mastery topics.

What i first put in the code was the library <iostream> to call all the fuctions of inputs and outputs of data in languague C++ #MasteryTopic06 Calling Functions and #MasteryTopic08

wsq3-v2
wsq3v3
wsq3v4
wsq3v5
wsq3v6
wsq3
Continue reading "#WSQ03 Post Pick a Number 23/01/17 and WSQ03.cpp"

#WSQ02 Post Temperature 23/01/17 and WSQ02.cpp

--Originally published at Solving Problems with Programming

Link of the picture: link of the picture

So in this fifth class that I had on last Monday we started how to make a program with conditions in C++.#Mastery10

What I did for this numeric program is solving the problem to the user by writing a program that will prompt the user for a temperature in Fahrenheit and then convert it to Celsius with the formula C = 5 ∗ (F-32)/9.

After that I modified the program to state whether or not water would boil at the temperature given.

The following photograph shows the solution to this problem:

temperature1

Picture of Author

So at first I wrote the same structure of the program just did the same as what i did in Hello World: Second Class, Second Blog (Blog of the second class 12/01/17) and Hello World.cpp and #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp where i explained the application of the #MasteryTopic01 that it is for comments that could be very useful when debugging and #MasteryTopic04 that is basic output for data.

What i first put in the code was the library <iostream> to call all the fuctions of inputs and outputs of data in languague C++ #MasteryTopic06 Calling Functions and #MasteryTopic08 Importing and using libraries.

code

Then i had to write a command that everytime goes with the instructions of input and outputs of data that is call std but with this command helps writing these std out of the main because the machine factorizes them.

Next I initialize the begin of my program int main().

After that i had to declarate just one basic type of variable in decimal  value for using in the math process of  C = 5 ∗ (F-32)/9. #Mastery03 #MasteryTopic03  because the program will show the value in a float way in celsius degrees.

Next

if
something-or-something-else-on
code
code2t
states
Continue reading "#WSQ02 Post Temperature 23/01/17 and WSQ02.cpp"