Write your question here.
i cant seem to understand how to place number to plug in on their own and be able to use a number being plugged in(Output a list of all divisors of numbers that are not prime and a list of divisors of all perfect numbers. Format your output so there are between 5 and 10 numbers per line .) if you can just explain that would be great really having trouble
#include <iostream>
#include <string>
#include <iomanip>
usingnamespace std;
//get their number
int main()
{
{
int perfectnumber;
int number;
char response, prime;
cout << "Not sure if its a prime number or perfect number." << endl;
cout << "Would you like to find out if your number is prime or perfect?" << endl;
cin >> response;
cout << "
if (response == 'Y' || response == 'y')
{
cout << "Please enter any number you would like to check" << endl;
cin >> number;
}
else if (response == 'n' || response == 'N')
{
cout << "thanks come try me again soon!" << endl;
system("pause");
return 0;
}
else if (response != 'y' || response != 'Y' || response != 'N' || response != 'n' )
{
cout << "wrong input try again" << endl;
system ("pause");
}
//prime
if ((number / 1 == number) && (number / number == 1))
{
cout << "It is a prime number!" << endl;
}
else if ((number % 2 == 0 || number % 3 == 0 || number % 4 == 0 || number % 5 == 0 || number % 6 == 0 || number % 7 == 0 || number % 8 == 0 || number % 9 == 0))
{
cout << "Not a prime :(" << endl;
}
//perfect number
{
int i=1,sum=0;
while(i<number){
if(number%i==0)
sum=sum+i;
i++;
}
if(sum==number)
cout << i << " is a perfect number!";
else
cout << i << " is not a perfect number :(";
system("pause");
return 0;
}
}
}
so i made it more complicated then it really is?
the thing is i know about bool and everything from watching tutorials online but since the teacher has not gone over it we gotta do it without void and bool. this is my first time making a program like this.
do you think i'm in the right direction anup30? with what i did.
and wow (unsigned int) didn't know i could use that.
really appreciate your help i'm going to see if i can use your formula without bool.
and if you know any video that can teach me c++ because my teacher is really complicating things and i'm scared of asking her for help because she tends to criticize us to other students because were bad.
sorry for writing so much first time looking for help