"veki" <ve***********@v-programs.comwrote in message

news:fh*********@enews2.newsguy.com...

Hello,

What shoud I change in this code to check, if some number is december:

#include <iostream>

#include <stdio.h>

using namespace std;

int main(){

int a,b;

int n=2;

int december=1;

cin>>a;

for(a/n;a<n;n++){

if (!(a%n)==0){

december=1;

}

else{

printf("Broj je prost");

}

}

scanf("\n");

return 0;

}

What you are trying to do is hard to ascertain. "December" in English is a

month of the year, the 12th month. But it seems you are trying to determine

if a number is prime or not (from others comments and your code) but it is

hard to determine what you are trying to do with the december variable.

Maybe you're trying to determine prime factors?

As for:

for(a/n;a<n;n++){

you probably meant

for(a=n;a<n;n++){

Yet, you are looking for the opposite, !(a%n)== 0 isntead of (a&n)==0. If a

number is evenly divisible, the remainder will be prime. So shouldn't this

be:

if ( a%n == 0 )

// Number is NOT prime

Now, it does no good to check just one number, you have to check them all.

Yet you are stating "Bjoj je prost" after every check. So I'm thinking that

december may be a flag you are trying to set. Mabe you want something like

this.

#include <iostream>

int main(){

int Number;

std::cout << "Enter number to check for prime:";

if ( std::cin >Number )

{

bool Prime = true; // Guilty until proven innocent

for( int i = 2; i < Number; i++){

if (Number%i ==0 ){

Prime = false;

break;

}

}

if ( Prime )

std::cout << "Number is prime\n";

else

std::cout << "Number is not prime\n";

}

return 0;

}