can anyone help me plz

can you solve this one for me ??


Write a C++ program to perform the following:
1) Input a positive integer total that represents the total distance in meters a person needs to travel.

2) Input a positive integer first that represents the distance of the first jump. This distance should be less than or equal to total/20. If first is greater than total/20 then set it to total/20.

3) Using a loop calculate how many jumps are needed to cover the total distance.
After every jump, the person jumps 1 meter more than the previous jump. See the
input and output for more examples.
Please note, that this is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attemts to solve this problem youself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. As it is impossible to find deriviative of function without knowledge in ariphmetics, you cannot do more complex tasks in programming without clear understanding of basics
actually i did it but it doesn't work

#include <iostream>
using namespace std;

int main(){

int total, jump ,i ;

cout << "Enter the total distance: ";
cin >> total;
cout << "distance of the first jump <=5 ";
cin >> jump;

if(jump > total/20)
jump = total/20;

for (int i = 0; jump + i <= total; i++)


cout << "You need " << i << " jumps to cover the total distance entered";

return 0;
}
surely you must want to use doubles instead of integers. Also you should divide by 20./20.0/20.0f not 20 since 20 is an integer and to get a floating-point you must divide by a double or float(both floating-point data types).
sorry but i didn't get the dividing point !! so i need to divied over 20.0 to be a float !! or what
Topic archived. No new replies allowed.