![]() |
|
#1
|
|||
|
|||
Programme for b/w two prime numbersi want programe r code b/w two prime numbers
Ex:1 to 19 prime numbers with the code r programe ............. |
|
#2
|
|||
|
|||
Re: programe for b/w two prime numbersI can't really tell what you're asking, but it looks like you want to write a program that inputs 2 numbers and prints every prime number in between them (inclusive). Is that correct? If so, here is a little template for you to start with:
CPP / C++ / C Code:
Now, all you have to do is write the function that will tell you if an integer is a prime number or not. |
|
#3
|
|||
|
|||
Re: programe to display all prime numbers in b/w given two numbersCPP / C++ / C Code:
take example as a=1 and b=20 and what's wrong in the programme can you tell please it display the error and tell me the correct code/programme Last edited by admin : 07-Dec-2007 at 09:29.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#4
|
|||
|
|||
Re: programe for b/w two prime numbersMy guess is that the line:
printf('is not a prime number"); is giving you an error. Try replacing it with: printf("is not a prime number"); Other than that, it probably won't work. If I were you, I would follow the example that I posted. When you break processes down into functions, it makes it a lot easier to debug. Start by creating a function that returns a boolean as to whether a number is prime or not. Something like: CPP / C++ / C Code:
Then, you should test just this function by itself before putting it in with the rest of the code. |
|
#5
|
|||
|
|||
Re: Programme to display prime numbers 1 - 20please send me a complete codo of programme how to display prime numbers from 1 to 20
|
|
#6
|
|||
|
|||
Re: Programme for b/w two prime numbers#include<iostream>
using namespace std; void main() { int w,x,y,z; for(x=2;w<=20;x++) z=0; { for(y=2;y<=x-i;y++) if(x%y==0) cout<<"z++"; } if(z==0) cout<<"x"; } |
|
#7
|
|||
|
|||
Re: Programme for b/w two prime numbersFor another example, see this thread.
|
Recent GIDBlog
NARMY by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Will pay through Paypal if somebody helps me. | paritoshcool | Assembly Language | 0 | 27-Nov-2007 22:27 |
| prime numbers | hiflya69 | CPP / C++ Forum | 5 | 19-Oct-2007 20:42 |
| Table | killer9012 | CPP / C++ Forum | 29 | 10-Oct-2006 21:15 |
| Python script: Prime numbers | crystalattice | Python Forum | 4 | 16-Apr-2006 08:19 |
| prime numbers | quasimof | CPP / C++ Forum | 1 | 01-Nov-2004 19:35 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The