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?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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
Double Helix STL
MatrixOriginally Posted by swgh
lift (before freeing Morpheus)
Neo looks up:
- There is no spoon, - and shouts the cabin down going with Trinity up.
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
I think I took it as the wrong verison of the meaning then. Thanks Vart.
Double Helix STL
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)