i am unable to understand the logic to be used. can u pls help me write the program

What have you tried so far? What exactly don't you understand? Keep in mind that we're not going to just give you the code for your program without some effort on your part.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.