Professional Documents
Culture Documents
CEC-101 P3 Operators
CEC-101 P3 Operators
2. Explain the purpose of the ternary condi�onal operator (?:). Provide an example of how it is
used.
3. Explain the difference between the assignment operator (=) and the equality operator (==)
with examples.
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
bool isPrime=1;
for(int i=2;i<n;i++){
if(n%i=0){
isPrime=0;
break;
}
}
if(!isPrime)
cout<<n<<" is prime";
else
cout<<n<<" is not a prime";
return 0;
}