Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Answercross-post Pin
led mike6-Nov-07 11:36
led mike6-Nov-07 11:36 
JokeRe: cross-post Pin
Rajesh R Subramanian6-Nov-07 21:15
professionalRajesh R Subramanian6-Nov-07 21:15 
AnswerRe: mfc - animation plus interaction (e.g draw a rotating square and drag it) Pin
Hamid_RT6-Nov-07 19:03
Hamid_RT6-Nov-07 19:03 
AnswerRe: mfc - animation plus interaction (e.g draw a rotating square and drag it) Pin
Nelek6-Nov-07 21:57
protectorNelek6-Nov-07 21:57 
AnswerRe: Bases conversion in C Pin
David Crow6-Nov-07 10:46
David Crow6-Nov-07 10:46 
GeneralRe: Bases conversion in C Pin
led mike6-Nov-07 11:33
led mike6-Nov-07 11:33 
GeneralRe: Bases conversion in C Pin
YNick6-Nov-07 12:14
YNick6-Nov-07 12:14 
GeneralRe: Bases conversion in C Pin
YNick6-Nov-07 12:28
YNick6-Nov-07 12:28 
i have tried to come up with my own way of having a code but its not working ...corect it please .
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/* Function Prototypes */
int bintodec(int fmbase, int num);
int dectobin(int tobase, int num);

int main()
{
int num;
int fmbase;
int tobase;
int result;
int convert;
int counter = 0;
int bin [25];
int quo = 1;

printf("Enter 0 to convert to binary\n");
printf("Enter 1 to convert to decimal\n");
scanf("%d",&convert);

printf("Enter the value to be converted:");
scanf("%d",&num);

printf("Enter base to be converted from: ");
scanf("%d",&fmbase);

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



if(convert ==0)
convert= dectobin();
else if (convert ==1)
convert= bintodec();
else
{
printf("Error in Input");
exit(1);
}
result = bintodec(fmbase,num);

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


result = dectobin(tobase,num);

printf("The result is:%d", result);
int dectobin( int tobase, int num)
do (quo!= 0)
{
quo= num/tobase;
bin[counter] = num%tobase;
counter ++;
num=quo;
}

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

int bintodec(int fmbase, int num)
{
int bin[256];
int counter ;
int counterR ;
int quo ;
int result =0;
int result1 =0;
int res[256];
int sum =0;

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

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

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

return sum;

}

system("PAUSE");
return 0;
GeneralRe: Bases conversion in C Pin
User 5838526-Nov-07 14:56
User 5838526-Nov-07 14:56 
QuestionRe: Bases conversion in C Pin
David Crow6-Nov-07 17:36
David Crow6-Nov-07 17:36 
AnswerRe: Bases conversion in C Pin
YNick7-Nov-07 0:55
YNick7-Nov-07 0:55 
GeneralRe: Bases conversion in C Pin
David Crow7-Nov-07 2:33
David Crow7-Nov-07 2:33 
GeneralRe: Bases conversion in C Pin
YNick7-Nov-07 4:14
YNick7-Nov-07 4:14 
QuestionRe: Bases conversion in C Pin
David Crow7-Nov-07 4:19
David Crow7-Nov-07 4:19 
QuestionHow to exchange message between different pages in tab control? Pin
Panamk6-Nov-07 8:43
Panamk6-Nov-07 8:43 
AnswerRe: How to exchange message between different pages in tab control? Pin
Maximilien6-Nov-07 9:02
Maximilien6-Nov-07 9:02 
GeneralRe: How to exchange message between different pages in tab control? Pin
Panamk6-Nov-07 9:09
Panamk6-Nov-07 9:09 
AnswerRe: How to exchange message between different pages in tab control? Pin
PJ Arends6-Nov-07 9:45
professionalPJ Arends6-Nov-07 9:45 
GeneralRe: How to exchange message between different pages in tab control? Pin
Maximilien6-Nov-07 9:51
Maximilien6-Nov-07 9:51 
GeneralRe: How to exchange message between different pages in tab control? Pin
Panamk6-Nov-07 10:55
Panamk6-Nov-07 10:55 
GeneralRe: How to exchange message between different pages in tab control? Pin
Panamk6-Nov-07 13:38
Panamk6-Nov-07 13:38 
GeneralRe: How to exchange message between different pages in tab control? Pin
Panamk6-Nov-07 13:39
Panamk6-Nov-07 13:39 
GeneralRe: How to exchange message between different pages in tab control? Pin
Nelek6-Nov-07 21:49
protectorNelek6-Nov-07 21:49 
AnswerRe: How to exchange message between different pages in tab control? Pin
Sam Hobbs6-Nov-07 15:57
Sam Hobbs6-Nov-07 15:57 
QuestionWindows Clipboard in C/C++: Migrating from VB6 to C Pin
Capitanevs6-Nov-07 7:22
Capitanevs6-Nov-07 7:22 

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.