This program had the purpose to make some operations.
An addition +
A substraction –
The product x
The division /
The reminder %
Here is the code for anyone in need and the proof it’s running.
Fundamentals and Solutions. Together!
Well hello! We meet again. So, after a rough past week (breaking up with my girlfriend of almost 2 years and 2 mid-partials)… I’m starting to feel a lil bit better so here we are, I’m way behind on assigments but luckily there’s no deadline. I will probably write about feelings in some future post, I don’t care, I can write whatever the fuck I want, right?
So, moving onto important matters, I looked up some codes from my friends to get some idea how to write de #WSQ03 Fun with numbers, and after seeing different methods, seems I took a bit of all worlds. Here’s my work:
The code, written in Atom:
The executable on Cygwin:
That’s it, I had to search St. Google for how to get the remainder, found out it’s the same as in C#, which I took last semester, using Visual Studio.
Now what? I still got a lot to do and read, and feelings-wise, as I heard somewhere I don’t really remember: “Going up shit creek without a paddle.”
This is goodbye for now. Just to leave you with another quote I like:
“Stay hungy, stay foolish” – Steve Jobs
Hello.
In this post I will show you basic math operations. Here’s the instructions:
- 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.
And this is the code:
It is a basic structure to have the difference, product, integer division and ramainder. As you can see I used variables. The variable tells the compiler where and how much to create the storage for the variable (http://www.tutorialspoint.com/cplusplus/cpp_ variable_types.htm).
The basic variable of Integer numbers is INT. As you can see in the image you have to write next to INT the variables that you want to use. In this case we have 6:
But now we are using CIN. The opposite of COUT. We have to use it when we want to ask to the user for values and put it here:
Under the COUT.
Then we write the operations with the respective variable.
Finally COUT is used to write the final message. To present the variable you have to write it between << variable << and it will show up the answer.
Thank you for see my post! See you Later.
The code we have to write for this task needs the following requirements:
I didn’t have any problems programming this, because I have programmed before in c++
This is the link to my code in Github → https://github.com/mfcanov/FunWithNumbers.git
Hello people!!, this is my new project on C++ and it’s called Fun With Numbers, made on Atom Editor and runned by Cygwin Terminal. I found easy to make it because I was reading about C++ on the link : http://www.cplusplus.com/doc/tutorial/variables/ , so I can do the project without any problem.
The new work to do in “Fun With Numbers”, is ask to the user for two values, and then, made some basic arithmetic operations. To do this, you have to declare the variables that are you asking or using, and then make the arithmetic.
And here is the program running on Cygwin Terminal.
The new commmands that I learned on this program were:
cin<<; that is used to read the value
int; to use integer numbers.
If you want to see the complete program go to the next link: https://github.com/eduardomrlsg/TC101/blob/master/funwithnumbers
Este es mi programa para en donde se reciben dos números y se realizan diferentes operaciones con esos dos números que se insertan, tales como resta, multiplicación, división y el residuo de esa división. este es el link de mi codigo.
yo para poder hacer este primer código, me tuve que apoyar en esta página, https://mx.answers.yahoo.com/question/index?qid=20130501130715AAsptxb todavía no entendí porque puso, PAUSE al final pero ignorando ese paso, y considerando conocimientos previos que tenia gracias al manejo de C#, pude hacer correr ese código.
Bueno, este programa fue muy fácil de hacer y… Aunque la forma de hacer este tipo de programas en este lenguaje de programación es muy similar a otros, la sintaxis más bien parece confundirnos un poco. Esta confusión es alimentada por nuestros conocimientos previos de otros lenguajes tales como C# o Java.
Lo primero que hice fue conseguir los libros necesarios (es español por supuesto) para aprender la manera correcta de llamar órdenes para posteriormente ejecutarlas y que el programa hiciera justo lo que yo quería que hiciera y este es mi código final.
Inmediatamente después de nuestro comentario acerca de lo que nuestro programa hace imprimimos un mensaje en pantalla animando a el usuario a introducir el primer dígito para posteriormente hacer las operaciones correspondientes, para lograr nuestro cometido primero nombramos a nuestra primera variable como ‘numero_a‘ esta variable estará seguida de un signo igual lo que significa que le asignaremos un valor, este valor será un valor en forma de dígito numérico que el usuario introduzca en la consola. Para esto usamos la orden ‘int(input())‘, la palabra ‘input()‘ nos indica que la consola se pausará un momento hasta que el usuario introduzca un valor, este puede ser un número o una letra mientras que la palabra ‘int()‘ nos ayudará a convertir el valor que el usuario introduzca a un valor entero (integer). La forma en que planteamos esta orden, ‘int(input())‘ es un buen ejemplo de que la Python y la concatenación de órdenes no están peleados de ningún modo.
Las demás variables son muy claras en cuanto a lo que significan con excepción de ‘.format(cociente)‘. Este orden puede parecer confusa al principio, pero con el tiempo se volverá de lo más normal pues es
código
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
int main()
{
float num1,num2,resultado;
int div;
char des, sig;
cout <<“Dame un numero”<< endl;
cin>>num1;
cout <<“Dame otro numero”<< endl;
cin>>num2;
do
{
cout <<“¿Que operacion quieres? Suma=S, resta=R, division entera=E, division con decimales=D”;
cin>>des;
switch(des)
{
case ‘S’:
case ‘s’:
resultado=num1+num2;
cout <<“El resultado es “<<resultado;
break;
case ‘R’:
case ‘r’:
resultado=num1-num2;
cout <<“El resultado es “<<resultado;
break;
case ‘E’:
case ‘e’:
div=(int)num1/num2;
cout <<“El resultado es “<<div;
break;
case ‘D’:
case ‘d’:
resultado=num1/num2;
cout <<“El resultado es “<<resultado;
break;
default:
cout <<“No elegiste algo”;
break;
}
cout <<“n¿Quieres continuar? si=s, no=n”;
cin>>sig;
} while(sig==’s’);
getchar();
return 0;
}
Ask the user for two integer values, then use those two values to calculate and show the following: