+ 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; }

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?

+ 1

Alright. well if you need help let me know. C++ is my main language

+ 1

1 question for you, what is the { for after the result 2 above double result;

+ 1

Ya remove one of the { and } glad u found your problem

+ 1

the 1 u just posted?

+ 1

ok well i followed u to keep up 👍

+ 1

thank you very much 😊

0

thanks.. m just complicating a simple code...
actually I m working on my algorithm making....

0

thanks Blake ..

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;
}

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

0

yeah...I know now thanks

0

hey blake... help me ...check my new post

0

yeah...thanks ...its working now...