#include <iostream>
using namespace std;

int main() {
	int numbers;
	numbers = 2;
while (numbers <= 1000);
{
	if (numbers % 2 ==0){cout<< numbers;};
	
	if	(numbers % 3 ==0){cout<< numbers;};
	 
		if	(numbers % 4 ==0){cout<< numbers;};
 
	if	(numbers % 5 ==0){cout<< numbers;};

		if	(numbers % 6 ==0){cout<< numbers;};

	if	(numbers % 8 ==0){cout<< numbers;};
	 
		if	(numbers % 9 ==0){cout<< numbers;};
 
	if	(numbers % 7 ==0){cout<< numbers;};
	
	if		(numbers % 11 ==0){cout<< numbers;};
++numbers;
}
cout<<numbers;
	return 0 ;
}

as you can see when i debug it, no digit will appear...how can i handle this one..need some help folks...

remove the semicolon after (numbers <= 1000)
as well as all the semicolons after the closing braces in your if statements

I believe you're attempting this:

#include <iostream>
using namespace std;
 
int main() {
	int numbers;
	numbers = 2;

	while (numbers <= 1000) {
		if (numbers % 2 ==0){cout<< numbers <<endl;}
	 
		if (numbers % 3 ==0){cout<< numbers <<endl;}
	 
		if (numbers % 4 ==0){cout<< numbers <<endl;}
	 
		if (numbers % 5 ==0){cout<< numbers <<endl;}
	 
		if (numbers % 6 ==0){cout<< numbers <<endl;}
	 
		if (numbers % 8 ==0){cout<< numbers <<endl;}
	 
		if (numbers % 9 ==0){cout<< numbers <<endl;}
	 
		if (numbers % 7 ==0){cout<< numbers <<endl;}
	 
		if (numbers % 11 ==0){cout<< numbers <<endl;}
		++numbers;
	}
	cout<<numbers;
	return 0 ;
}

thanks men!! youre # 1!! but how can have spacing between digits??

cout<<numbers<<"      "<<numbers<<endl;

sir...but how can i get this sorter..by using int divi for its divisible..to get even the highest possible prime number extracted?

You're on the right track, but you're not getting the prime number part correct.

Try re-writing the inside of your while loop

and remove the cout << numbers after the loop, as you wouldn't want to print anything there


in other words

#include <iostream>
using namespace std;
 
int main() {
	int number;
	number = 2;

	while (number <= 1000) {

                ...
		IF number IS PRIME THEN
                   PRINT number
                ...

		++number;
	}

	return 0 ;
}
#include <iostream>
using namespace std;

int main() {
    int numbers;
    int divi;
    numbers = 2;
    divi = 0 ;

while (numbers <= 1000)
{
    if (numbers % divi ==0){numbers++;};

cout<< numbers<< "\t";

divi++;

}

    return 0 ;
}

this is my update on this

[B]isPrime = true

num = 2

while num <= 1000
     for i in( 2 to num/2 )
	    if num % i = zero
                isPrime = FALSE
	    endif
     endfor
	
     if isPrime = TRUE
         PRINT num
     endif
	
     increment num
     isPrime = TRUE
endwhile[/B]
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.