- 5

Who know C++

29th Oct 2020, 6:30 PM
Jo'shqinbek Bekniyozov
Jo'shqinbek Bekniyozov - avatar
15 Answers
+ 2
Please describe the problem.
29th Oct 2020, 6:31 PM
Seb TheS
Seb TheS - avatar
+ 2
Jo'shqinbek Bekniyozov Ur while loop should be like this:- while(a<=b) {sum+=(1/a); a++; }
30th Oct 2020, 3:35 AM
~प्रिया
~प्रिया - avatar
+ 2
You can learn from here https://www.cplusplus.com , it really helped me understand! you should practice when you learn something!
30th Oct 2020, 5:15 AM
BatOchir Artur
BatOchir Artur - avatar
+ 1
Why there is a++ included twice in the loop? Why are you using sum = sum + 1 (incrementing sum by 1) while you were supposed to increment sum by a fraction?
29th Oct 2020, 6:44 PM
Seb TheS
Seb TheS - avatar
+ 1
You were supposed to increment sum by a fraction, not by sum itself.
29th Oct 2020, 6:50 PM
Seb TheS
Seb TheS - avatar
+ 1
but its still better, currently all the problems are located on this statement: sum += sum;
29th Oct 2020, 6:50 PM
Seb TheS
Seb TheS - avatar
+ 1
With fraction I mean't 1/1, 1/2, ... 1/n in the problem description. I can give hint that variable a represents n in the list. (a = 1, 2, ... b)
29th Oct 2020, 6:58 PM
Seb TheS
Seb TheS - avatar
+ 1
If this is a role call, I guess I'll say "Here"
29th Oct 2020, 8:42 PM
Maxwell Anderson
Maxwell Anderson - avatar
0
Using while loop to calculate S=1/1+1/2+.....+1/n
29th Oct 2020, 6:33 PM
Jo'shqinbek Bekniyozov
Jo'shqinbek Bekniyozov - avatar
0
#include<iostream> using namespace std; int main() { int a=1, b; double sum = 0; cout << "enter the number = "; cin >> b; while ( a <= b, a++) { sum = sum+ 1; a++; } cout << "sum is " << sum << endl; system("pause"); return 0; } It is not calculate sum Only input valur
29th Oct 2020, 6:36 PM
Jo'shqinbek Bekniyozov
Jo'shqinbek Bekniyozov - avatar
0
#include<iostream> using namespace std; int main() { int a=1, b; double sum = 0; cout << "enter the number = "; cin >> b; while ( a <= b ) { sum += sum; a++; } cout << "sum is " << sum << endl; system("pause"); return 0; }
29th Oct 2020, 6:46 PM
Jo'shqinbek Bekniyozov
Jo'shqinbek Bekniyozov - avatar
0
Also the same problem
29th Oct 2020, 6:47 PM
Jo'shqinbek Bekniyozov
Jo'shqinbek Bekniyozov - avatar
0
Sum is 0😕😕
29th Oct 2020, 6:48 PM
Jo'shqinbek Bekniyozov
Jo'shqinbek Bekniyozov - avatar
- 1
Thank you
30th Oct 2020, 5:21 AM
Jo'shqinbek Bekniyozov
Jo'shqinbek Bekniyozov - avatar
- 2
Please help me
29th Oct 2020, 6:31 PM
Jo'shqinbek Bekniyozov
Jo'shqinbek Bekniyozov - avatar