Search Results

Showing results 1 to 40 of 107
Search took 0.01 seconds.
Search: Posts Made By: hammerhead ; Forum: C++ and child forums
Forum: C++ Jun 4th, 2008
Replies: 14
Views: 3,809
Posted By hammerhead
@Deepak
Do not give away the solution. Read the last point of this link http://www.daniweb.com/forums/thread78223.html

Also posting C code in C++ forum is not a good idea that too without code...
Forum: C++ May 25th, 2008
Replies: 3
Views: 376
Posted By hammerhead
Typecasting worked for me

if(i % 2 == 0) s -= 1/(float)(i*i);
else s += 1/(float)(i*i);
Forum: C++ May 21st, 2008
Replies: 10
Views: 1,525
Posted By hammerhead
>>but howcome my version didnt classify as recursion when it did indeed call the function inside itself?

I didn't think it did because it does not fall into the conventional definition of...
Forum: C++ May 21st, 2008
Replies: 10
Views: 1,525
Posted By hammerhead
I dont think your code classifies as recursion. Neither does it satisfy the question


This is what I would do to check if a link list is sorted using recursion

bool sorted(node *curr)
{
...
Forum: C++ May 15th, 2008
Replies: 3
Views: 536
Posted By hammerhead
@ Ancient Dragon, the recursive function is incorrect. foo(x) has to return int. The correct version would be


int foo(int x)
{
if(x < 10)
{
x = x + 1;
return foo(x);
...
Forum: C++ May 15th, 2008
Replies: 5
Views: 453
Posted By hammerhead
You have declared variables x,y,z as members of the class and also as parameter values of the function arith_ex
do something like this

void Calculator::arith_ex(int x,int y,int z)
{
...
Forum: C++ May 15th, 2008
Replies: 10
Views: 782
Posted By hammerhead
For two matrices to be equal, the dimensions of both matrices have to be equal and the corresponding values should also be equal. I would follow niek_e's method to compare two matrices.
Forum: C++ May 13th, 2008
Replies: 4
Views: 583
Posted By hammerhead
Insert line 20 inside the while loop and add the statement prev=prev->link; at the end of the loop.
Forum: C++ May 11th, 2008
Replies: 10
Views: 697
Posted By hammerhead
For Q14

The else is binded to the second if statement, but note that the second if itself will be executed only if the first 'if' holds true. Its like saying
if(condition)
{
if(condition)
...
Forum: C++ May 11th, 2008
Replies: 10
Views: 697
Posted By hammerhead
Lets take Q3, you have to know that void means that the function does not return any value. That means that option C is incorrect and A is perfectly valid. Option B is where one might get stuck, but...
Forum: C++ May 11th, 2008
Replies: 7
Views: 951
Posted By hammerhead
An alternative could be using link list if you want to do it without STL. That way your first issue would be solved, but still the best way would be using vectors.
Forum: C++ May 11th, 2008
Replies: 10
Views: 697
Posted By hammerhead
What is there you cannot understand? If you expect someone to hand out the answers then you are wrong.
Forum: C++ May 11th, 2008
Replies: 3
Views: 498
Posted By hammerhead
You have created Node<K> *root; before defining the class Node. Declare it after the class. Furthermore I dont think you can use Node<K> n; outside the class. You will have to specify a valid class...
Forum: C++ May 10th, 2008
Replies: 6
Views: 860
Posted By hammerhead
No you cannot. But you can pass the variables by reference so that the changes are reflected in the original variables. For example

void test(int &a,int &b)
{
a=a+1;
b=b+1;
}

int...
Forum: C++ May 8th, 2008
Replies: 9
Views: 521
Posted By hammerhead
First of all please keep in mind to post your code using the code tags (http://www.daniweb.com/forums/announcement8-3.html). You have not done so even after Lerner told you.


total = total +...
Forum: C++ May 8th, 2008
Replies: 3
Views: 1,085
Posted By hammerhead
Forum: C++ May 1st, 2008
Replies: 5
Views: 465
Posted By hammerhead
No I cannot. Do your own work yourself. Your last post is a lame attempt to make others do your work. Also read this http://www.catb.org/~esr/faqs/smart-questions.html
(Hope Salem dosn't mind me...
Forum: C++ May 1st, 2008
Replies: 14
Views: 3,400
Posted By hammerhead
Please use code tags (http://www.daniweb.com/forums/announcement8-3.html) to post your code in future. A lot of energy of mods is spent on telling others to do the same it is the least you can do if...
Forum: C++ May 1st, 2008
Replies: 15
Solved: Mirror Numbers
Views: 1,325
Posted By hammerhead
You are not using your head and instead simply copy pasting the code. If you had read any of the posts above the mistake in my code would have been clear to you.
Forum: C++ May 1st, 2008
Replies: 5
Views: 465
Posted By hammerhead
One way to about it would be to enter randomly either a 'X' or an 'O' at every turn of the computer. But this solution would not be very smart.

Another method could be exhausting all the possible...
Forum: C++ May 1st, 2008
Replies: 15
Solved: Mirror Numbers
Views: 1,325
Posted By hammerhead
number1 = number % 10;
number=number/10;
number2 = number % 10;
number=number/10;
number3 = number % 10;
Forum: C++ May 1st, 2008
Replies: 15
Solved: Mirror Numbers
Views: 1,325
Posted By hammerhead
No you are not. The base of the numbers is 10 not 100 or 1000. And you have used cout the wrong way


cout << endl << number<< number2<<number3;
Forum: C++ May 1st, 2008
Replies: 15
Solved: Mirror Numbers
Views: 1,325
Posted By hammerhead
A hint, divide a number by 10. The quotient would be the number except for the least significant digit and the remainder would be the least significant digit. Use these two in combination to get your...
Forum: C++ Apr 30th, 2008
Replies: 10
Views: 1,633
Posted By hammerhead
Here are a few errors I can see

int List::sumOfNodes();

remove the ';' at the end.


while( currentPtr ! = null)
Forum: C++ Apr 28th, 2008
Replies: 3
Views: 405
Posted By hammerhead
People here are not psychic. Kindly explaing what problem are you having with the code.
Forum: C++ Apr 27th, 2008
Replies: 26
Views: 2,107
Posted By hammerhead
I am not sure, it has worked for me and I have never bothered to search. I will leave it for more experienced programmers to answer your question.
Forum: C++ Apr 27th, 2008
Replies: 26
Views: 2,107
Posted By hammerhead
There is no need to use floor() as int truncates any decimal place as it is.

for any 4 digit number this should do the trick to extract all 4 digits

i=0;
while(number>0)
{
a[i]=number%10;...
Forum: C++ Apr 27th, 2008
Replies: 26
Views: 2,107
Posted By hammerhead
Its not

cin >> number,first,second,third,fourth;


but

cin >> number>>first>>second>>third>>fourth;
Forum: C++ Apr 27th, 2008
Replies: 6
Views: 791
Posted By hammerhead
Line 24, it just default, not case default


default:
cout << endl << "INVALID SELECTION!";
break;


And you cannot declare variables starting with numeral. Try this
Forum: C++ Apr 26th, 2008
Replies: 8
Views: 695
Posted By hammerhead
I dont mind being called a geek because that is more or less what I am :)

Note that the '==' operator does not apply to float. You would get the output as C++ if you tried

if(f==.7)
Forum: C++ Apr 26th, 2008
Replies: 2
Views: 418
Posted By hammerhead
For a client server model, you will have to code seperately for the server and seperately for the client. The server will basically keep track of all the data like scores, players etc. And the...
Forum: C++ Apr 26th, 2008
Replies: 15
Views: 1,615
Posted By hammerhead
Okay one way to go about this would be using getline() (http://www.cplusplus.com/reference/iostream/istream/getline.html) to get the entire line. Use any delimiter to split the line into three...
Forum: C++ Apr 26th, 2008
Replies: 27
Views: 3,929
Posted By hammerhead
The formula can be generalized as

index= ((row_num-1)*3) + (col_num-1)

where index is the index in the array
row_num is the row number of the element you want to refer and
col_num is the...
Forum: C++ Apr 25th, 2008
Replies: 1
Views: 459
Posted By hammerhead
for(int i=countDown;i>=0;i-- )
Forum: C++ Apr 25th, 2008
Replies: 1
Views: 680
Posted By hammerhead
mover is a pointer to wheel_node and contents is an int You cannot equate them as you have done in Line 6.

In order to create the link list you have to allocate memory using the new operator to...
Forum: C++ Apr 25th, 2008
Replies: 12
Views: 2,286
Posted By hammerhead
No one here is going to code anything for you. You are better off with learning C++ and start coding on your own. The worst part of all this is that you expect people to do all the research and then...
Forum: C++ Apr 25th, 2008
Replies: 12
Views: 2,286
Posted By hammerhead
Why cant you do it yourself?
Forum: C++ Apr 25th, 2008
Replies: 27
Views: 3,929
Posted By hammerhead
Number of colums in the first matrix have to be equal to the number of rows in the second one. If you have only a row or a column matrix i.e. two arrays, their lengths have to be equal in order for...
Forum: C++ Apr 24th, 2008
Replies: 15
Views: 1,615
Posted By hammerhead
@majestic0110
Random numbers come after applying the formula, it is however only to fool the end user :D. Lets say for example that I get result as '5' after application of the formula. Now I can...
Forum: C++ Apr 24th, 2008
Replies: 15
Views: 1,615
Posted By hammerhead
That depends on how you want the love percentage to be calculated and if you want it to be the same for a given set of names. For example you can say that the love percentage will be higher if the...
Showing results 1 to 40 of 107

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC