Welcome Guest
Established
This is wrong. Your code tests a number if it is even or odd but not if it's a prime number.#include<iostream>
using namespace std;
int main()
{
int c;
int g;
cout<<"Enter Number: ";
cin>>c;
g=c%2;
if(g!=0)
cout<<c<<" is a prime number";
else
cout<<c<<" is not a prime number";
}
Ts try mo to hindi nga lang forloop pero simplify codes lang hahha
ask po ano po ba ung prime? sorry mahina ako sa math ehhThis is wrong. Your code tests a number if it is even or odd but not if it's a prime number.

Thanks kahit mali haha... Prime number po is divisible only by 1 or its self.ask po ano po ba ung prime? sorry mahina ako sa math ehh![]()
#include<iostream>
using namespace std;
bool isPrime(int number){
for(int i = 2 ; i < number ; i++){
if(number % i == 0)
return false;
}
return true;
}
int main(void){
cout<<"Prime Numbers from 1 to 50"<<endl;
for(int i = 1 ; i <= 50 ; i++)
if(isPrime(i))
cout<<i<<" is a prime number"<<endl;
else
cout<<i<<" is not a prime number"<<endl;
}