+ 1

help me guys ....i want to use division lemma... a=bq+r => a/b=q+r/b....i want to divide two integers ...in complicated way

#include <iostream> using namespace std; int main() { int a,b,result1,result2; cout<<"enter a"; cin>>a; cout<<endl<<"enter b"; cin>>b; result1=a/b; cout<<endl<<"result1 :"<<result1<<endl; result2=a%b; cout<<"result2 :"<<result2<<endl; { double result; double c=result2/b; cout<<"c : "<<c<<endl; result=result1+c; cout<<"result :"<<result<<endl; } return 0; }

22nd Mar 2017, 6:22 PM
Laraib
Laraib - avatar
14 Answers
+ 1
#include <iostream> using namespace std; int main() { int a, b, quotient, remainder; cout << "Enter a number: "; cin >> a; cout << "Enter another number: "; cin >> b; quotient = a/b; remainder = a%b; cout << "Quotient: " << quotient << endl; cout << "Remainder: " << remainder << endl; //Lemma a = b*quotient + remainder; quotient += remainder / b; cout << endl << "By lemma:" << endl; cout << "a" << a << "=>" << quotient << endl; return 0; } Is this what you are trying to do?
30th Mar 2017, 8:56 PM
Blake Lynch
Blake Lynch - avatar
+ 1
Alright. well if you need help let me know. C++ is my main language
31st Mar 2017, 2:46 AM
Blake Lynch
Blake Lynch - avatar
+ 1
1 question for you, what is the { for after the result 2 above double result;
31st Mar 2017, 2:49 AM
Blake Lynch
Blake Lynch - avatar
+ 1
Ya remove one of the { and } glad u found your problem
31st Mar 2017, 2:59 AM
Blake Lynch
Blake Lynch - avatar
+ 1
the 1 u just posted?
1st Apr 2017, 5:26 PM
Blake Lynch
Blake Lynch - avatar
+ 1
ok well i followed u to keep up 👍
1st Apr 2017, 5:28 PM
Blake Lynch
Blake Lynch - avatar
+ 1
thank you very much 😊
1st Apr 2017, 5:29 PM
Laraib
Laraib - avatar
0
thanks.. m just complicating a simple code... actually I m working on my algorithm making....
31st Mar 2017, 2:45 AM
Laraib
Laraib - avatar
0
thanks Blake ..
31st Mar 2017, 2:46 AM
Laraib
Laraib - avatar
0
#include <iostream> using namespace std; int main() { int a,b,result1,result2; cout<<"enter a"; cin>>a; cout<<endl<<"enter b"; cin>>b; result1=a/b; cout<<endl<<"result1 :"<<result1<<endl; result2=a%b; cout<<"result2 :"<<result2<<endl; { double result; double g=result2; double c=g/b; result=result1+c; cout<<"result :"<<result<<endl; } return 0; }
31st Mar 2017, 2:47 AM
Laraib
Laraib - avatar
0
I don't know ..why it put it there ..... but when I was making it... ...and I removed the { my code was not working then according to what I want........ but now I know the problem wasn't the {....it was something else
31st Mar 2017, 2:56 AM
Laraib
Laraib - avatar
0
yeah...I know now thanks
31st Mar 2017, 4:28 AM
Laraib
Laraib - avatar
0
hey blake... help me ...check my new post
1st Apr 2017, 5:09 PM
Laraib
Laraib - avatar
0
yeah...thanks ...its working now...
1st Apr 2017, 5:27 PM
Laraib
Laraib - avatar