Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

this is my program,what's the problem?int main() {int a,b,s,n; float q; cin>>b; s=0; while(s14 years ago

OpenStudy (anonymous):

What language is this

OpenStudy (anonymous):

I'm working on visual C++

OpenStudy (anonymous):

at first glance, it looks correct. What is it doing wrong?

OpenStudy (anonymous):

oh wait, you're using n in the loop, but it wasn't initialized.

OpenStudy (anonymous):

you just need one loop. initialize n to 1, and in the while loop, add 1/n to s, then increase n by 1.

OpenStudy (rsmith6559):

s=s+q; would demote q from a float to an int, also.

OpenStudy (anonymous):

yes, that too :-)

OpenStudy (anonymous):

s should be a float or double.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
3 days ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
3 days ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!