Fun with Numbers

--Originally published at TC1017 Programing Curse

In the first assignment, it is about asking the user for two integer values, then use those two values to calculate the sum, the diference, the product, the division and the remainder of it, but with no decimal point. To do this, i use the book to  learn about how to declare integer variables…

To start i declare the variables, 2, used to obtain the values from the user and 1 to print the results, at first i did the sum, then the diference, after it, the product, and at the end the division and it reminder.

#include <iostream>
using namespace std;

int PrimerNumero ;
int SegundoNumero;
int resultado;

}

int main() {
cout <<“Escribe el primer numero”<< endl;
cin >> PrimerNumero;
cout << “Escribe el segundo numero”<< endl;
cin >> SegundoNumero;
cout << “Los resultados son”<< endl;
cout << “suma= ” << PrimerNumero+SegundoNumero << endl;
cout << “resta= ” << PrimerNumero-SegundoNumero << endl;
cout << “Multiplcacion= ” << PrimerNumero*SegundoNumero << endl;
cout << “Division= ” << PrimerNumero/SegundoNumero << endl;
cout << “Residuo= ” << PrimerNumero%SegundoNumero << endl;
cout << z << endl;
return 0;
}


Let’s have fun with… numbers??

--Originally published at Loading…

This is what Ken asked us to do:

Ask the user for two integer values, then use those two values to calculate and show the following:

  • The sum of 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 remainder of integer division of the two numbers.

So the first thing that I did was to declare all my variables as an integer with “int”. n01 and n02 are for the numbers to print on the terminal. Then the other 5 variables are for each one of the results of the operations that the program had to realize.  Later I put the instruction of cout to show the message “Enter the number” (and all the others messages) and cin in order that the user could give the value to the variable with the number that he wishes. Finally to give a value to n03 (or the others 4 variables) I wrote the formula for each operation, and print the result on the screen.

This is my code:

hwphoto3hwphoto4

It was nice to remember the basic things!! 


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

--Originally published at Solving Problems with Programming

Picture of the author.

First let me tell you that in my last week 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 I explained it in my post: 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

In this week i learned more mastery topics besides of the mastery ones i learnt from last week. I learned these mastery topics:

#Mastery01 #Masterytopic01 #MasteryTopic01 #MASTERY01 #MASTERYTOPIC01 that i talked in my blog: #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp

In this week i learned the #Mastery02 #Masterytopic02 #MasteryTopic02 #MASTERY02 #MASTERYTOPIC02 that is C++ Good Style coding conventions. I achieve this mastery arranging the spaces between the sentences of my code and also by doing plugins for my c++ codes after my teacher give me this feedback:

ken.png

With this link Code »Posting Source Code i used this part of code to use while posting my c++ code in a better way on my last post #WSQ01 Post Fun with Numbers 16/01/17 and WSQ1.cpp . The code i used for it is this:

plugin2

Link of image: Code »Posting Source Code

While you are going to publish your code on C++ in the wordpress editing page you need to copy paste this short code and change the extension of the code, instead of “css” will be the

plugin3
c3
Continue reading "Post of the week #2 what things i learned in this week #2 ?"

WSQ 01 Fun with numbers!

--Originally published at Programming the city

Hello people, today I want to show you a code where the user types 2 integer numbers and the program makes the sum, difference, product, division and the reminder of the division between both numbers.

Here is the code:


#include <iostream>
using namespace std;

int main()
{

int num1, num2, sum, difference, product, division, reminder;

cout<<“Give me a number “;
cin>>num1;

cout<<“Give me one more number “;
cin>>num2;

sum=num1+num2;
difference=num1-num2;
product=num1*num2;
division=num1/num2;
reminder=num1%num2;
cout<<“The sum of the numbers you just gave me is “<<num1<<“+”<<num2<<“=”<<sum<<endl;

cout<<“The difference between the numbers you just gave me is “<<num1<<“-“<<num2<<“=”<<difference<<endl;

cout<<“The product of the numbers you just gave me is “<<num1<<“x”<<num2<<“=”<<product<<endl;

cout<<“The division of the numbers you just gave me is “<<num1<<“/”<<num2<<“=”<<division<<endl;

cout<<“The reminder of the integer division is “<<reminder<<endl;
return 0;
}


As you can see, I added the int variables for each math operation, you have to know that the name of the variables is up to you.

Then, you have to input everything you need to, for example the variable sum, you just have to type the two variables and between them, type +, and automatically it will make the sum. For the other operations, is the same path, but with different symbols(-,*,/,%).

Here is the evidence.

wsq01

#WSQ 01

#TC1017


WSQ 01

--Originally published at OlafGC / Class #TC1017

Here you have it… WSQ 01. The program is very simple: You give the computer 2 numbers and the computer do different operations with them. In this program, there is no need to add additional libraries, you just use <iostream>. So here’s the code and how it works. If you have any questions, you can contact me in the twitter link on top of my blog.

Code:

#include <iostream>

using namespace std;

int main()
{
int n1, n2, sum, dif, pro, divi, rema;
cout<<“Give me two numbers and I’ll calculate its sum, difference, product, division and remainder from division.”<<endl;

cout<<“Give me your first number:”<<endl;
cin>>n1;
cout<<“Give me your second number:”<<endl;
cin>>n2;
sum=n1+n2;
cout<<“The result of the sum is “<<sum<<“.”<<endl;

dif=n1-n2;
cout<<“The result of the difference is “<<dif<<“.”<<endl;

pro=n1*n2;
cout<<“The result of the product is “<<pro<<“.”<<endl;

divi=n1/n2;
cout<<“The result of the division is “<<divi<<“.”<<endl;

rema=n1%n2;
cout<<“The remainder of the division is “<<rema<<“.”<<endl;
return 0;
}

wsq01


1. First Code: “Hello World”

--Originally published at Programming the city

In this blog, we will be programming in the text editor Atom, then we will save our files as cpp, for example: helloworld.cpp. After that we will run the program in Cygwin(program), this is a tool collection that help us with executable codes. 

Today I will show you the text or the code of my first program, Hello World.


#include
using namespace std;

int main(){
| cout << “Hello world” << endl;
return 0;
}


helloworld2

As you can see, I’m only printing the word Hello World, just to know how Atom and Cygwin work.

Here is the code running.

helloworld

And there it is.

First we select the library, then we type g++ and the File name and at the end, we type ./a.exe.

#TC1017

#WSQ01


WSQ 01 – Fun with Numbers

--Originally published at The Talking Chalk

I am glad to announce you my cpp file “Fun with Numbers” has worked nicely.

Being this my second contact with C++ yet the first course of this programming language I ever had, it took me time to understand the way C++ works; but it was not such a deal.

For the making of this homework I consulted the youtube videos C++ Tutorial 2 – Variables, user input and math operators, and C++ Program Input and Output.

Firstly, I determined the values of number as zero, later I wrote the text that would appear on screen  asking for the value of the first number so its respective variable acquires that number for value. The same process was done for the second number to be used on the forthcoming operations.

Secondly, interpretate as int the result of the mathematical operations (addition, substraction, multiplication, division and its remainder) between both numbers.

Lastly, the programs shows on screen the ints of the five mathematical operations, statifying which is what.

Results were satisfying.

 

funwithnumbers1

funwithnumbers2

#include <iostream>
#include <string>

using namespace std;

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;

int sum_values = number_one + number_two;
int dif_values = number_one – number_two;
int prod_values = number_one * number_two;
int div_values = number_one / number_two;
int rem_values = number_one % number_two;

cout << “The sum of these values is equal to: ” << sum_values << “.” << endl;
cout << “The difference of these values is equal to: ” << dif_values << “.” << endl;
cout << “The

meinlove
Continue reading "WSQ 01 – Fun with Numbers"

Integral fun

--Originally published at World&#039;s Fanciest Cursors

It’s time to play with numbers. Here I’ll show you an unnecessarily overcomplicated program that could have been achieved in one third of the lines of code used. To achieve this ugly mess I used control statements (while loops  and if statements), switch cases and functions. Click on each of those phrases to take you to the tutorial I used to learn how to use them.

Today’s featured cursor is the ¯\_(ツ)_/¯ cursor, for when you don’t know what to do and just shrug it of..

cursor-of-the-day
Source

Here’s the code:

#include <iostream>
#include <cmath> // Library for more in depth math, needed for absolute values

int numbercruncher (int, int, int); // prototyping a function

int main()
{
int loopy = 1;
std::cout << “Human, I eat numbers. Feed me.\n”;
while (loopy == 1) // This repeats the process so that you can do it again
{
loopy = 0;
int uno = 0, dos = 0;
char decide;
std::cout << “\nWhat’s your first integer number?” << std::endl;
std::cin >> uno;
std::cout << “What’s your second integer number?” << std::endl;
std::cin >> dos;
std::cout << “This is what I have to say about your numbers:” << std::endl;
std::cout << “Their sum is ” << numbercruncher (uno, dos, 1) << std::endl; // The constant number indicates what part of the function to run
std::cout << “Their difference is ” << numbercruncher (uno, dos, 2) << std::endl;
std::cout << “Their product is ” << numbercruncher (uno, dos, 3) << std::endl;
std::cout << “Their integer division is ” << numbercruncher (uno, dos, 4) << std::endl;
std::cout << “Their division remainder is ” << numbercruncher (uno, dos, 5) << std::endl;
std::cout << “\nWold you like to enter more numbers? (y/n)” << std::endl;
std::cin >> decide;
if (decide == ‘y’)
{
loopy =

Continue reading "Integral fun"

First assignment

--Originally published at The Clueless Programmer

I see you came back for more of my programming magic, welcome. Ok what I have for you today is certainly a more difficult program than the “Hello World” one, but was still fairly easy to program.

Basically the assignment asked us to make a program that asks the user to input two numbers, and the sums, substracts, multiplies and divides them giving us all the different results. This is an example of the program with two numbers I chose randomly:

sin-titulo

#include <iostream>
using namespace std;
int main()
{
int num1, num2, res;
cout<<“Please enter a number “<<endl;
cin>>num1;
cout<<“The number you entered is “<<num1<<endl;
cout<<“Please enter a second number “<<endl;
cin>>num2;
cout<<“The number you entered is “<<num2<<endl;
res=num1+num2;
cout<<“The sum of “<<num1<<” + “<<num2<<” is “<<res<<endl;
res=num1-num2;
cout<<“The difference of “<<num1<<” – “<<num2<<” is “<<res<<endl;
res=num1*num2;
cout<<“The product of “<<num1<<” * “<<num2<<” is “<<res<<endl;
res=num1/num2;
cout<<“The integer based division of “<<num1<<” divided by “<<num2<<” is “<<res<<endl;
res=num1%num2;
cout<<“The remainder integer of “<<num1<<” divided by “<<num2<<” is “<<res<<endl;
}

As you can see, the program asks you to give it two numbers and then, because it is super smart, does the operations for you, so if one day you don´t feel like doing simple math then all you have to do is turn on your computer and open this program! Way cooler than a calculator am I right?

I basically named the variables first, then asked the user to input two numbers, the parts where I printed a lot of useless information was just to try out some output stuff, they are not really necessary. Then you just do the operations, saving them on the variable, and print them, easy. I was able to program this easily because of the previous knowledge I had acquired on a course I took

Continue reading "First assignment"