![]() |
can't add to value ! .. urgent plz help
Hi
I can't add to the same variable !! Code:
unsigned long int Convert(char input[], int base)case 1: value=1 i= 2 n= 0 case 0: value=0 i= 0 n= 2 case 1: value=4 i= 0 n= 1 final answer = 4 ------ where final answer should be 5 it's not adding to value... it's just displaying the final digit calculation :( plz help.. I need to fix that in less than an hour.. |
Re: can't add to value ! .. urgent plz help
The values of a text 0 ('0') and text 1 ('1') are not the same as the values 0 and 1. As a matter of fact, the value 0 ('\0' or nul) is the sign of the end of a string.
You also have syntax errors. It's "+=", not "=+". You have so many errors that it's a wonder you got the program to run. Are you sure that you reproduced it correctly in the post? Make sure you have all errors and warnings enabled, and make a trip back to your books. Also, make sure that the term, 'base', is not confusing you. For "pow", it's not the numeric base, it's the number to be raised to the exponent (the second argument). |
Re: can't add to value ! .. urgent plz help
oh that's really strange ! my program run with this syntax error (=+) !
I've fixed it :) .. here's my program working fine.. - NOW i'm going to write the print function by the way do you have a way to do the convert function without having these many cases !! .. Code:
#include <stdio.h> |
Re: can't add to value ! .. urgent plz help
oh I forgot to write [/code] in my previous post ! ..
I could not edit my previous post too ! there's no icon for that ! |
Re: can't add to value ! .. urgent plz help
you can try the program..
the output of 10010011 base 2 is 147 ;) the output of BACD base 16 is 47821 :) |
Re: can't add to value ! .. urgent plz help
Quote:
|
| All times are GMT +5.5. The time now is 14:14. |