Click here to Skip to main content
15,896,538 members
Home / Discussions / C#
   

C#

 
AnswerRe: Base Conversion Pin
Christian Graus5-Nov-07 8:56
protectorChristian Graus5-Nov-07 8:56 
GeneralRe: Base Conversion Pin
YNick5-Nov-07 11:51
YNick5-Nov-07 11:51 
GeneralRe: Base Conversion Pin
Colin Angus Mackay5-Nov-07 13:40
Colin Angus Mackay5-Nov-07 13:40 
GeneralRe: Base Conversion [modified] Pin
Colin Angus Mackay5-Nov-07 13:38
Colin Angus Mackay5-Nov-07 13:38 
GeneralRe: Base Conversion Pin
YNick5-Nov-07 15:51
YNick5-Nov-07 15:51 
GeneralRe: Base Conversion Pin
PIEBALDconsult5-Nov-07 16:13
mvePIEBALDconsult5-Nov-07 16:13 
GeneralRe: Base Conversion Pin
Colin Angus Mackay5-Nov-07 22:40
Colin Angus Mackay5-Nov-07 22:40 
GeneralRe: Base Conversion Pin
YNick6-Nov-07 6:27
YNick6-Nov-07 6:27 
i got 2 codes separate after trying to do it over and over again:here is the binary to decimal code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/* Function Prototypes */
int bintodec(int fbase, int number);



int main()
{
int number;
int fbase;
int tobase;
int result;

printf("Enter base from: ");
scanf("%d",&fbase);

printf("Enter your number:");
scanf("%d",&number);

printf("Enter base to convert to: ");
scanf("%d",&tobase);

result = bintodec(fbase,number);

printf("The result is:%d", result);


system("PAUSE");
return 0;

}


int bintodec(int fbase, int number)
{
int bin[256];
int counter =0;
int counterR =0;
int quo =1 ;
int result =0;
int result1 =0;
int res[256];
static int sum =0;

while(quo>0)
{
quo= number/10;
bin[counter] = number%10;
number=quo;
counter++;
}

while (counter>0)
{
result = pow(fbase, (counter-1));
result1=result*bin[counter-1];
res[counterR]=result1;
counter--;
counterR++;
}

while (counterR > 0)
{
sum = sum + res[counterR-1];
counterR--;
}

return sum;

}



and the decimal to binary code :

#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main()
{
int tobase=0;
int number =0;
int counter = 0;
int bin [25];
int quo = 1;

printf("Enter your number:");
scanf("%d",&number);

printf("Enter base to convert to: ");
scanf("%d",&tobase);



while (quo!= 0)
{
quo= number/tobase;
bin[counter] = number%tobase;
counter ++;
number=quo;
}

while (counter > 0)
{
printf( "%d", bin[counter-1]);
counter --;
}

system("PAUSE");
return 0;
}


Now i need to know how to get both of these codes into 1 complete source code for bases conversion.and also asking the user to either convert decimal to binary vice-versa ......
this is the furthest i can go so please help me.
GeneralRe: Base Conversion Pin
Colin Angus Mackay6-Nov-07 6:50
Colin Angus Mackay6-Nov-07 6:50 
GeneralRe: Base Conversion [modified] Pin
YNick6-Nov-07 7:28
YNick6-Nov-07 7:28 
GeneralRe: Base Conversion Pin
Colin Angus Mackay6-Nov-07 9:03
Colin Angus Mackay6-Nov-07 9:03 
QuestionEventArgs Pin
half-life5-Nov-07 7:35
half-life5-Nov-07 7:35 
AnswerRe: EventArgs Pin
Judah Gabriel Himango5-Nov-07 7:58
sponsorJudah Gabriel Himango5-Nov-07 7:58 
GeneralRe: EventArgs Pin
half-life5-Nov-07 8:07
half-life5-Nov-07 8:07 
GeneralRe: EventArgs [modified] Pin
TJoe5-Nov-07 8:12
TJoe5-Nov-07 8:12 
GeneralRe: EventArgs Pin
half-life5-Nov-07 8:15
half-life5-Nov-07 8:15 
GeneralRe: EventArgs Pin
half-life5-Nov-07 8:14
half-life5-Nov-07 8:14 
GeneralRe: EventArgs Pin
Pete O'Hanlon5-Nov-07 10:10
mvePete O'Hanlon5-Nov-07 10:10 
GeneralRe: EventArgs Pin
half-life5-Nov-07 10:14
half-life5-Nov-07 10:14 
GeneralRe: EventArgs Pin
half-life5-Nov-07 10:16
half-life5-Nov-07 10:16 
GeneralRe: EventArgs Pin
Pete O'Hanlon5-Nov-07 10:30
mvePete O'Hanlon5-Nov-07 10:30 
Question[WPF] Pin
LordArcane5-Nov-07 6:46
LordArcane5-Nov-07 6:46 
QuestionIntPtr to Delegate in .NET 1.1 Pin
__DanC__5-Nov-07 6:42
__DanC__5-Nov-07 6:42 
AnswerRe: IntPtr to Delegate in .NET 1.1 Pin
Judah Gabriel Himango5-Nov-07 7:11
sponsorJudah Gabriel Himango5-Nov-07 7:11 
GeneralRe: IntPtr to Delegate in .NET 1.1 Pin
__DanC__5-Nov-07 22:03
__DanC__5-Nov-07 22:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.