#[code]include <iostream>
usingnamespace std;
voidint main(){
int choice;
float number;
while(choice !=4){
cout<< "Welcome to my first program! Please choose one of the menu choices below:" <<endl;
cout<< "1 Check if a number is prime."<<endl;
cout<< "2 Reverse display a number."<<endl;
cout<< "3 Check if the reverse of a number is prime."<<endl;
cout<< "4 Quit."<<endl;
cout << "Please enter your menu choice: " << endl;
cin >> choice;
cout<< "Enter your number:" <<endl;
cin >> number;
if(number >= 0) {
//choice 1
if(choice==1) {
for(float i=1; i<= number; i++){
if(number% i!=0){
cout<< "Number is prime:" <<endl; }
else {
cout<< "Number is NOT prime:" <<endl; } } }
elseif(choice == 2) {
float new_num;
while(number > 0){
new_num = new_num*10 + (number % 10);
number = number/10;
}
cout << new_num << endl; }
elseif(choice == 3){
float new_number;
while(number > 0)
{
new_number = new_number*10 + (number % 10);
number = number/10;
}
cout << "The reversed number is: " << new_number << endl;
for(float i=0; i<= new_number; i++){
if(new_number% i!=0){
cout<< "New number is prime:" <<endl; }
else {
cout<< "New number is NOT prime:" <<endl; } } }
elseif(choice== 4){
cout<< "Goodbye." <<endl;
return 0;
}
}
else {
cout << "Your number is invalid because it is less than 0." << endl;
}
}
The % modulus operator expects integer values, but in several cases the code is using float values.
There is the fmod function in the <cmath> library (http://www.cplusplus.com/reference/cmath/fmod/), but it seems like you could just change your float variables to integers if you're going to be checking for primes.
while(choice !=4) - choice has not been initialized with a value before you try to compare it to 4 here.
If you can edit your post, highlight the code, then click the button with <> in the Format palette to the right of the post to add code tags, that would help others to read the code :)