Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can not figure out the algorithm for a problem. The problem is below :

Q. There is a city where a person never ages more then 40. Once you reach 40, your age starts decreasing i.e. 39,38,37....10. Once you reached 10, your age will increase again i.e 11,12,13....40. This goes for infinite times.


Can anyone give the program code(its better for me to understand in 'C') or the algorithm for the problem above.?

What I have tried:

I can not figure out algorithm
Posted
Updated 17-Jul-17 9:31am
Comments
Dave Kreskowiak 17-Jul-17 12:42pm    
Nope, we're not doing your homework for you.
jeron1 17-Jul-17 12:45pm    
Can you put the algorithm on a piece of paper?

Take a look at the while loop, here is some information about it: while loop in C[^]
 
Share this answer
 
Quote:
Q. There is a city where a person never ages more then 40. Once you reach 40, your age starts decreasing i.e. 39,38,37....10. Once you reached 10, your age will increase again i.e 11,12,13....40. This goes for infinite times.

This describe a situation, but as there is no question, so there is no algorithm to solve the non question.
Quote:
I can not figure out algorithm

Take a sheet of paper and pencil and try to solve your problem by hand, the provedure you follow is your algorithm.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900