In This Code, Shown Below, Find The String W/c Satisfies The Problem...
This is a discussion on Division By Subtraction within the C++ Programming forums, part of the General Programming Boards category; In This Code, Shown Below, Find The String W/c Satisfies The Problem......
In This Code, Shown Below, Find The String W/c Satisfies The Problem...
Turbo C Makes me Sick....i just want to learn data structures in latest c++
Le Tormente (fr. the torment)
Code:#include <iostream.h> #include <conio.h> int main() { int x; int y; int product = 0; cout<<"input first number:"; cin>>x; cout<<"input second number:"; cin>>y; for(int i=0; i<x; i++) { product +=y; } cout<<"Product is:"<<product; getch(); return 0; }
Turbo C Makes me Sick....i just want to learn data structures in latest c++
Le Tormente (fr. the torment)
#include <iostream>
remove conio.h
and replace getch by something portable (see FAQ)
your program calculates x*y using addiction.
So what is the problem? you want to replace addiction with substraction to calculate x/y? Or what?
The first 90% of a project takes 90% of the time,
the last 10% takes the other 90% of the time.
using subtraction to calculate x/y
Turbo C Makes me Sick....i just want to learn data structures in latest c++
Le Tormente (fr. the torment)
so show the code that USES substruction, and describe your problem with itOriginally Posted by blacksnake
The first 90% of a project takes 90% of the time,
the last 10% takes the other 90% of the time.
the problem looking for is input two numbers and compute for division using subtraction operator...
Turbo C Makes me Sick....i just want to learn data structures in latest c++
Le Tormente (fr. the torment)
It is not a problem - just assignment description. Show your code you have a problem withOriginally Posted by blacksnake
The first 90% of a project takes 90% of the time,
the last 10% takes the other 90% of the time.
Is there a problem with this code?Code:#include <iostream.h> int main() { int x; int y; int rem; int quotient = 0; cout<<"input first number:"; cin>>x; cout<<"input second number:"; cin>>y; for(int i=0; i<y; i--) { quotient -=x; } cout<<"Quotient is:"<<quotient<<"Remainder is:"<<rem; return 0; }
Turbo C Makes me Sick....i just want to learn data structures in latest c++
Le Tormente (fr. the torment)
could you explain your algorithm? in English?
The first 90% of a project takes 90% of the time,
the last 10% takes the other 90% of the time.
process:
1. Input two numbers
2. compute for division but using subtraction operator...just like multiplication using addition
3. compute for the remainder(rem=x/y)
example for process#2 :
100/10=10
100-10-10-10-10-10-10-10-10-10-10=0
Turbo C Makes me Sick....i just want to learn data structures in latest c++
Le Tormente (fr. the torment)
@Vart
A little off topic, but does that mean somthing to do with the ladies? You "grab a spoon" or somthing of that context? Lol., sorry but Im intersted in the quote.there is no spoon
I'm just trying to be a better person - My Name Is Earl
MatrixOriginally Posted by swgh
lift (before freeing Morpheus)
Neo looks up:
- There is no spoon, - and shouts the cabin down going with Trinity up.
The first 90% of a project takes 90% of the time,
the last 10% takes the other 90% of the time.
So you shouldOriginally Posted by blacksnake
count number of substructions before y goes to 0.
you don't know it in the beginning
when finished counter contains a result, y - reminder of divisionCode:1. counter = 0 2. if (y > x) {y-=x; counter++} 3. goto 2
Now write it in more details, and then - write a code that does it
The first 90% of a project takes 90% of the time,
the last 10% takes the other 90% of the time.
I think I took it as the wrong verison of the meaning then. Thanks Vart.
I'm just trying to be a better person - My Name Is Earl
it is a little bit confused, is it possible to use for loop to satisfy the equation?Originally Posted by vart
Turbo C Makes me Sick....i just want to learn data structures in latest c++
Le Tormente (fr. the torment)