Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Program to accept three number n1 n2 and p from the user and find the even number between the n1 and n2(including n1 nad n2) now your task is to only print all the pth even number between n1 and n2. Example n1=2 n2= 20 p=3 All even number between n1 and n2 are 2 4 6 8 10 12 14 16 18 20 Here p=3 So print every third even number from the sequence so output will be 6 12 18

What I have tried:

I have tried it to take out even numbers between two number ,and thought to store that numbers in in array and then to print every 3rd element of array.
Posted
Updated 22-Apr-22 9:47am
Comments
merano99 22-Apr-22 15:03pm    
Show us your source code and ask specific questions about it. There will be no solution service here.
Note on the solution here: The numbers should only be output, storing all numbers in an array does not seem to be required.
0x01AA 22-Apr-22 15:10pm    
And I thought, you had that shift today :-)
Richard MacCutchan 23-Apr-22 4:02am    
You do not need to store anything. You just need a couple of loop counters: one counts from n1 to n2 in even increments (i.e. 2), and the other counts from 1 to p, and prints every pth number.

1 solution

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
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