frogboy77 73 Posting Pro in Training

Played half a game(well). Still gutted. (the Mrs aint)

frogboy77 73 Posting Pro in Training
frogboy77 73 Posting Pro in Training

Missed that:(

frogboy77 73 Posting Pro in Training

In your program say i enter the number x=7

in your loop it goes

x(7)%i(2)!=0 so prime == 1
x(7)%i(3)!=0 so prime == 1
x(7)%i(4)!=0 so prime == 1 //needless since it cannot divide by 2
x(7)%i(5)!=0 so prime == 1
x(7)%i(6)!=0 so prime == 1 //same again
x(7)%i(7)==0 so prime == 0

If a number x, is not divisible by 2 then it can't be divisible by anything above x/2
If a number x, is not divisible by 2 or 3 then it can't be divisible by anything above x/3
etc...

frogboy77 73 Posting Pro in Training

Good kick under a little bit of pressure, but a foul that makes the terrible sending off in the world cup look like a gentle hug.
The Mrs is happy so therfore i am happy.:)

The Super Bowl is an eighties soap (Dallas) but slightly faster and less interesting.

frogboy77 73 Posting Pro in Training

I have sent a memo to the PM asking for the Scottish team to be let loose in the wild then hunted by men on horses with a lot of dogs. He has yet to reply.:(

frogboy77 73 Posting Pro in Training

Try here.

frogboy77 73 Posting Pro in Training

works fine for me on an old compiler using windows

frogboy77 73 Posting Pro in Training

the second term of the array and add it with the third term of this array

you are taking the third item twice i.e 3+3

frogboy77 73 Posting Pro in Training
vector<vector<int>> vec(a, vector<int>(b));

Is this compilable? (i.e without the white space)

frogboy77 73 Posting Pro in Training

I think you want to look at this.

frogboy77 73 Posting Pro in Training

ok so number =3145
you need a nested loop so you can check pos1vpos2 pos1vpos3 pos1vpos4 pos2vpos3 etc...(or work back from pos4vpos3 doesn't matter)
(google bubble sort if you need to)
then you need to isolate the 2 numbers into variables, say a and b
i started my outer loop with i=length-1 and decremented i.
so a=num/pow(10.0,i)
a=(int)a%10
the 2 lines are because pow requires pow(double,int). got some compiler warnings with this.(I told you it was ugly)
inner loop starts at j=i-1
so b= same as above but with j not i.
now you have the 2 numbers to compare
if they need to be swapped then take them away from number ie number-=3000,number-=100 then add back in number+=1000, number+=300 (leave that code to you)

easterbunny commented: well written and usefull +1
frogboy77 73 Posting Pro in Training

OK just done it i think.
Use a while loop for the length of the number.
Then sort the number checking each digit against the next (bubble sort) after separating them into 2 variables using / % and pow. If they need swapped remove the variables multiplied by the corresponding pow - then add by multiplying the variables by the correct pow and they should have swapped places. Using a nested loop to go right through the number.
Sorry i don't think i've explained it very well.

EDIT
Just ran it again and zeros are an issue. Doesn't work with them.
That can be fixed by checking the length at the end against the length at the start and outputting the appropriate number of zeros before the number.(UGLY i know)
Except leading zeros but who uses those.

frogboy77 73 Posting Pro in Training

I gave you the answer dude.

frogboy77 73 Posting Pro in Training

What are 5 and 6 supposed to compute?
5) maybe %5
6) maybe /5

frogboy77 73 Posting Pro in Training

Break is used for stopping a loop. You are not using a loop.

frogboy77 73 Posting Pro in Training

if (ope == '+')

frogboy77 73 Posting Pro in Training

ope should be a char

frogboy77 73 Posting Pro in Training

Without the braces the loop only executes the one command after then exits after it has finished, then you output the final value of k.

frogboy77 73 Posting Pro in Training

{} braces around your loop

frogboy77 73 Posting Pro in Training

Frogboy,
You pretty much got what i needed bang on, But hahaa,
Dude you did all the work for me lol >"<

VERY little work involved.

frogboy77 73 Posting Pro in Training

I see no mention in the original post concerning arrays.
Again with no error checking.
Maybe i'm reading this all wrong but what's wrong with

#include <iostream>

using namespace std;

int main()
{
    int quiznum;
    double total=0,result,average;
    cout<<"Enter amount of quizes: ";
    cin>>quiznum;
    
    for(int i=1;i<=quiznum;++i)
    {
            cout<<"Enter result: ";
            cin>>result;
            total+=result;
    }
    
    average=total/quiznum;
    
    cout<<"\nThe average is "<<average<<"\n";
    if(average>=75) cout<<"Pass\n";
    else cout<<"Fail\n";
    
    return 0;
}
frogboy77 73 Posting Pro in Training

Why do you have 2 loops when you just add to sum after line 16.
This can be easily done without the need for arrays.

frogboy77 73 Posting Pro in Training

For b) what about

((1 + (rand() % 5)) * 2)+1;
frogboy77 73 Posting Pro in Training

Sorry it was pretty late. The code was not intended to be handed in as is. The point i was trying to convey was that there seemed to be a lot of unnecessary work being done. Basically you only need to check the first character of the string against the last, then the second against the second last etc.. until you reach the middle.

frogboy77 73 Posting Pro in Training
#include <iostream>
#include <string>

using namespace std;

bool is_pal(string a)
{
     int b=a.length();
     for(int i=0;i<(b/2);++i)
             if(a[i]!=a[b-i-1])return false;
     return true;
}

int main()
{
    string s;
    cout<<"Please enter a string:\n";
    cin>>s;
    if(is_pal(s)) cout<<"This is a palindrome.\n";
    else cout<<"This is not a palindrome.\n";
    
    return 0;
}
frogboy77 73 Posting Pro in Training

Why the { on line 27?
What if n%10=1? i.e n=11 or 21?

EDIT
Beat me to that Nick:)
I have also been led to believe goto is BAD. A while or do while loop may be better.

frogboy77 73 Posting Pro in Training

You're in over your head. Get a book and start reading. :)

frogboy77 73 Posting Pro in Training

It is repeating the loop. Try a couple of cout lines to find out where you're going wrong(ie right before line 21).

frogboy77 73 Posting Pro in Training

The world has lost a salesman (admittedly a good one).

frogboy77 73 Posting Pro in Training

I doubt she's going to do everything for you. Unless she's in a really really really good mood.

frogboy77 73 Posting Pro in Training

I'm not sure with only partial code but on line 10 do you want to be incrementing j before the output on line 11?

frogboy77 73 Posting Pro in Training

you could try

srand(time(NULL));

worked in the past for me but hey i'm not good at this so "pinch of salt".

frogboy77 73 Posting Pro in Training

@sergent
RUN FOR THE HILLS!

frogboy77 73 Posting Pro in Training

Don't stop helping, i haven't seen a rant like this in ages.:twisted::D

frogboy77 73 Posting Pro in Training

Are the big eyes an aspiration or an identity crisis?

frogboy77 73 Posting Pro in Training

I think on line 27 distKilo is undeclared in that scope. It is not global(and i wouldn't recommend that) so on line 13 it will always output0.0

more like

cout << "Total miles in kilometers is : " << calcKM(numMiles) << endl;

remove line 10
and declare distKilo as a double in your function.

frogboy77 73 Posting Pro in Training

or

#include <iostream>

using namespace std;
int readmiles( );
double calcKM(int numMiles);

int main( ) // calls readmiles & calcKM
{
int numMiles = 0;
double distKilo = 0.0;
numMiles = readmiles( );
calcKM(numMiles);
cout << "Total miles in kilometers is : " << distKilo << endl;
system("pause"); 
return 0;
}

int readmiles( ) //inputs number of miles
{
cout <<"Enter number of miles: ";
cin >> numMiles;
return numMiles;
}

double calcKM(int numMiles) // calculates miles into kilometers
{
distKilo = numMiles * 1.67;
return distKilo;
}

I think this would work. I don't know wether you would need to use void with readmiles??

frogboy77 73 Posting Pro in Training

Even after all that help it's still "do it for me"?

frogboy77 73 Posting Pro in Training

wrong.
see this.
How is 3 a factor of 25.
@the OP ignore this nonsense.

frogboy77 73 Posting Pro in Training

You have a global variable N which you give no value, then you pass this to perfect with no declared value, then inside perfect you ask the user for a value of N.
This can't be good.
Also why call isfactor from main when it's being called from perfect.
I'm not to sure what to #include in programs but 2 out of 4 look unnecessary (not sure if the conio.h is for getch(),probably).

frogboy77 73 Posting Pro in Training

I'm feeling pretty bad about the "boo u", but you starting to try to do your own work is rewarding.
You should probably down my rep. It would have been much easier if i had gave you the answer.

frogboy77 73 Posting Pro in Training

@jonsca
Are you the most patient man on the planet?

frogboy77 73 Posting Pro in Training

ha ha... very cleaver ;P

Would that mean extremely like a large knife?

P.S I can keep this up all day.

frogboy77 73 Posting Pro in Training

what and where do i plug things in to discover it?

generally speaking, the computer and the socket in the wall.

frogboy77 73 Posting Pro in Training

You could use another variable eg y=2, and make x+=y, then increment y in the loop. Although this wouldn't work for the first number, an extra cout before the loop would do the trick though.
Be aware this is probably a very unelegant way of doing it.

frogboy77 73 Posting Pro in Training

I believe he is suggesting compiling the program, checking the output and then now that you know the answers figuring out how they came to be so. If i'm wrong jonsca please correct me (don't want to put words in your mouth).:)

frogboy77 73 Posting Pro in Training

Wales should do better, i now have to listen to a welsh woman ranting and raving for probably the next couple of days (hopefully only that long).:yawn:

frogboy77 73 Posting Pro in Training

Can't even win a bloody spoon!

frogboy77 73 Posting Pro in Training

I think Scotland are in need of a cutlery item, preferably made from some natural substance from the forest, with which they can take turns beating each other.