help!
what is the program of a simple c++ program of identifying if the number entered is prime or not using while loop.. is it possible to program without using bool??

what is the program of a simple c++ program of identifying if the number entered is prime or not using while loop..

It's a Prime Number Test Program.

is it possible to program without using bool??

yes.

can anyone show me the code of prime number program using while loop but without using bool..?

can anyone show me the code of prime number program using while loop but without using bool..?

Can you use google, or do it yourself?

i dont know how, thats why i'm asking for help.. and i cant find any prime number program in google that uses while loop but doesnt use bool.

Edited 5 Years Ago by mrSatellite: n/a

//enter the given rang from keyboard
//u will get prime no from given range
//13-11-20103
//prime_rng.cpp



#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int st_no,end_no,div,no_div=0;
cout<<"Enter the starting no ";
cin>>st_no ;
cout<<"Enter the enging no ";
cin>>end_no ;

        while(st_no<=end_no)
        {  div=st_no;
            no_div=0;

            while(div>=1)
            {
                if(st_no%div==0)
                {
                no_div= no_div+ 1   ;
                }
                div--;
            }

if(no_div<=2)
{
cout<<st_no<< "  IS  PRIME"<<endl<<endl;
}
st_no++;

            }
return 0;
}

Edited 4 Years Ago by deceptikon: Added code tags, removed personal information

Comments
Do NOT do homework for others. YOU dont get the grade!

i dont know how, thats why i'm asking for help.. and i cant find any prime number program in google that uses while loop but doesnt use bool.

Well anything we would write for you would be using modern, standard C++ instead of your 30 year old outdated non-standard C++ that you compile with Borland Turbo C++. So you can see the problem with us writing a program for you every time you're too lazy to use a search engine to learn something.

Yeah, and in place of the bool use an integer, use the value "0" for false and "1" for true. Enjoy your wasted programming "skills".

Comments
wtf
//enter the given rang from keyboard
//u will get prime no from given range
//safwan hashmi
//email was here
//13-11-20103
//prime_rng.cpp
...

Very bad code:
1) terrible formatting - inconsistent
2) using code that at least 15 years old
3) using headers that ate at least 10 years old and have been replaced
4) using functions that no compiler uses to this day
5) Massaging your ego and giving out code that allows the OP to cheat

Good Job!

And thank you for posting your email address so web-bots can harvest it and add you to thousands of SPAM lists.

Comments
stupid
Point well made

i m studnt . i learn progrmming from start, "means" from simple C.first i learned basic things of programming .
if u people dose not like this post . plz rmve me from daniWeb .i will learn programming to other c++ webssite .
thnkx

num 2 and 3 are primes
if num mod 6 = 1 or num mod 6 = 5
it is possible to be a prime.
or the number is a result of ( prime num * another prime num )
otherwise it is not a prime number.
i hope this will help you.

thnk you (pseudo) for your comments.. i didnt know people here are rude..
hope you *** due to your EXCELLENT programming SKILLS!

thnk you (pseudo) for your comments.. i didnt know people here are rude..
hope you *** due to your EXCELLENT programming SKILLS!

I'm quite happy you feel as such. But isn't that a threat? :( Daniweb likely frowns upon threatening other members.

I'm sorry I called your programming "skills" wasted, I'm sure they're quite useful to you and your people. But for most of the rest of the world, we require "ISO/IEC C++ 2003".

Please see http://en.wikipedia.org/wiki/C%2B%2B
for information regarding future revisions to the C++ standard.

Edited 5 Years Ago by pseudorandom21: n/a

Very bad code:
1) terrible formatting - inconsistent
2) using code that at least 15 years old
3) using headers that ate at least 10 years old and have been replaced
4) using functions that no compiler uses to this day
5) Massaging your ego and giving out code that allows the OP to cheat

Good Job!

**And thank you for posting your email address so web-bots can harvest it and add you to thousands of SPAM lists.
people on Daniweb total disapoint and degrade student..How cheap :( that y many aur class flow lve Daniweb including me .and they Join other forums they learn better **

Edited 4 Years Ago by HASHMI007

Well testing for primes can be a very bad job when you deal with a mathematical problem involving very big numbers.The test for prime for a number x should be carried up to less than equal to sqrt(x). //I came across a program to find the sum of all primes below 2 million.I ran my code without considering sqrt and it took more than some 5 minutes on my i7 2nd Gen.And yes another category for testing primes is that all of them are of the form 30k + i where k is any whole number and i belongs to {3,7,11,13,1719,23,29}

Edited 4 Years Ago by delta_frost

can anyone show me the code of prime number program using d0-while loop but without using Turboo C++..?

This article has been dead for over six months. Start a new discussion instead.