C++ problems plz plz help me friends
Plz solve this 3 programs for me if possible.i m not able to get coding .
1. bool inside= !((x<left)||(x>right)||(y<top)|| (y>bottom));
2. bool no =
3. given 1+3+....(2p-1)=p(square) for any integer p>=1. here i need a function which find out whether a given number is a perfect square. here i cant use array, nested looops, math functions and arithmetic operations except addition.
Plz Plz help me guys i really great full to u. :nonod:
thanx for giving me ur precious time.:lipsrseal
Re: C++ problems plz plz help me friends
I don't understand the problem with 1 and 2 and "i'm not able to get coding" - you already have coding. Are you trying to understand what the code does? Both seem pretty obvious though from the naming: could it be that "inside" tells you if x and y are inside something?
3. OK, this isn't difficult. Have you thought how you might do it? Do you think a for statement might be useful? If so what would the three expressions within the for statement be? What do you think might need to happen within the loop?
Here's a possible algorithm: start with 1 and compare it with the number under test. What do you think "less than", "equal" and "greater than" would imply? If you haven't found a result, go onto the next square (4, found by adding 3). Compare with the number under test again. If you decide continue, add 5 to get to the next square (9), and repeat. Repeat until what? If the current square is less than the number under test you know what to do (continue looping), if they're equal then you've found that the number under test is a square, so would the repeat continue until something is greater than something?
Pretty much written it for you there. Have a go at writing the code and see how far you get. Think carefully about the code. When you're stuck, try to solve the problem yourself and only post the code here if you're really stuck.
|All times are GMT +5.5. The time now is 05:19.|