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

double u es cue zero one…NO! IT’S THE WSQ05

--Originally published at The Talking Chalk

This surely was easy. I have already the power of the functions in my veins, flowing and flowing like a rainbow through the cloudy skies.
Here comes dat Chalk.
int waddup(waddup)
{
return waddup
}
Here comes dat Chalk.
Watch him coding.
Watch his bash.
Watch him coding.
Watch his bash.
Jokes aside, I only had to créate a function for each task and return in each the designated mathematical operation of the two parameters.
#include <iostream>
#include <string>
using namespace std;
int sum(int x ,int y)
{
return x+y;
}
int abst(int x ,int y)
{
return x-y;
}int mult(int x ,int y)
{
return x*y;
}
int divid(int x ,int y)
{
return x/y;
}
int remain(int x ,int y)
{
return x%y;
}
int main()
{
int number_one = 0;
int number_two = 0;
 cout << “Enter an integer value:” << endl;
cin>> number_one;
 cout <<“You chose: ” << number_one << “.” << endl;
 cout << “Enter another integer value: \n”;
cin>> number_two;
cout << “You chose: ” << number_two << “.” << endl;
 cout << “The sum of these values is equal to: ” << sum(number_one, number_two) << “.” << endl;
cout << “The difference of these values is equal to: ” << abst(number_one, number_two) << “.” << endl;
cout << “The product of these values is equal to: ” << mult(number_one, number_two) << “.” << endl;
cout << “The division of these values with no decimals is equal to: ” << divid(number_one, number_two) << “.” << endl;
cout << “The remainder of these values is equal to: ” << remain(number_one, number_two) << “.” << endl;
 return 0;
}

On to functions!

--Originally published at my programming blog

What we needed to do in this assignment was to use the first program we did and make functions ( like the addition, difference, division, etc.).

This assignment was easy because I only needed to do simple functions.

  1. So the first thing I did was to make my functions, I named them Sum, Difference, Product, Division and Remainder.
  2. Then in the parameters I included the integers a and b.
  3. And in the return value I put (a+b), (a-b), (a*b), (a/b) and (a%b).
  4. Then I made the int main
  5. Then I asked the user for two integers and then I printed the results of each function.

Here is my code:

#include <iostream>
using namespace std;

int Sum(int a, int b){return (a+b);}
int Difference(int a, int b){return (a-b);}
int Product(int a, int b){ return (a*b);}
int Division(int a, int b){return (a/b);}
int Remainder(int a, int b){return (a%b);}

int main()
{
int a, b;
cout<<“Please enter two integers:”<<endl;
cin>>a>>b;
cout<<“The sum of these integers is: “<<Sum(a,b)<<endl;
cout<<“The difference between the integers is: “<<Difference(a,b)<<endl;
cout<<“The product of the integers is: “<<Product(a,b)<<endl;
cout<<“The division of the integers is: “<<Division(a,b)<<endl;
cout<<“The remainder of the division of the integers is: “<<Remainder(a,b)<<endl;
return 0;
}

screen-shot-2017-02-16-at-8-52-15-am

When I run it, it gives something like this:

screen-shot-2017-02-16-at-8-53-03-am

Thanks for reading! I hope it helps


WSQ05

--Originally published at TC1017

This program can be used as a calculator, it does the same that WSQ01(Fun with numbers) just that the code is written in a different way.

Link to the code : https://docs.google.com/document/d/11FaIPuPiMdPmcJmYYp6VYog-xbblDAtM2w9699bOxyg/edit?usp=sharing

#BAPL


Homework 5: Calculator

--Originally published at Let&#039;s CODE

This program will make some basic operations. It’s just like the program of the first homework, but using functions. We have to create 5 functions: sum, subtraction, multiplication, division and remainder. Each function must read two integer parameters (the same for each one) given for the user. Also, we have to declare another variable which … Continue reading Homework 5: Calculator

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:

WSQ05 – On To Functions

--Originally published at Programming the city

Hello guys, as usual, this week I created a code like the first one I did(FUN WITH NUMBERS) but with functions.

It was kind of easy but I had a little obstacle when making the division, I named the variable div, but Cygwin told me there was an error there. The solution was, changed the name of the variable.

So here is the code….


wsq05-1wsq05-2


 

And the result is…..

wsq05-3There you go.


Now with functions!

--Originally published at Loading…

This one was pretty easy! Actually we had to do the same that in our first program but now using a function for every operation. So now that I already know how to do functions was simple enough and fast to do this activity.

The first thing that I did was open my WSQ01 project and I copied and pasted it in a new file. I wasn’t sure if there exist functions for each operation, so I googled and this page really helped me to do all the activity.

These are my functions, easy: function0And this is the main, what the program shows:
function01And it runs correctly… I think. function02

I hope I was able to help you, if you have any question don’t doubt to send a message.


Back to where we started

--Originally published at Ken&#039;s Disciple 01

Picture by Unsplash Unsplash

Hello TC1017, this blog is about the #WSQ05, which is actually very easy since is just modifying the original #WSQ01, and also adding stuff you “already know”.

For this task I didn’t need anything special, just the things I already knew, so since this one might be easy I recommend starting to learn how to use #Github, you just create an account as usual, like in any other social media, and if you want to know how to use GitHub, I also recommend ken’s tutorial, which is awesome, you only need 10 minutes and you are good to go.

So back to the program, the only thing you need is to write your functions, and remember to Return what you want, the easiest thing to put in here is the actual operations. Here’s my code and some examples of how it works.

Captura de pantalla 2017-02-07 a la(s) 10.32.33.png

This are the functions with their parameters. And this is what’s inside the main:

Captura de pantalla 2017-02-07 a la(s) 10.33.50.png

As you can see, pretty easy, this is how it looks like running:

Captura de pantalla 2017-02-07 a la(s) 10.31.44.png

Captura de pantalla 2017-02-07 a la(s) 10.31.57.png

If you want to see my code, here it is on GitHub: code.

If you have any questions feel free to ask.

L.out