#include<stdio.h>
#include<conio.h>
#include<ctype.h>

char c,ch;          //choosing
long int dec,quotient;  //
long int *pdec;         //
int bin[100],i=1,j;     //Binary
int *pbin,*pi,*pj;      //
long int octal,*poctal; //Octal
long int hexa,*phexa;   //Hexadecimal

main()
{
clrscr();
gotoxy(5,7);
printf("A. Binary");
gotoxy(5,8);
printf("B. Octal");
gotoxy(5,9);
printf("C. Hexadecimal");
gotoxy(5,5);
printf("Convert decimal to: ");
scanf("%c",&c);
c=toupper(c);


{
    if(c=='A')
    {
    clrscr();
    pdec=&dec;
    pbin=bin;

    gotoxy(5,5);
    printf("Enter any decimal number: ");
    gotoxy(8,8);
    scanf("%ld",pdec);
    quotient = *pdec;

    while(quotient!=0)
        {
        pbin[i++]= quotient % 2;
        quotient = quotient / 2;
        }

    gotoxy(20,8);
    for(j=i-1;j>0;j--)
        {
        printf("%d",bin[j]);
        }
}
    else if(c=='B')
       {
       clrscr();
       poctal=&octal;

       gotoxy(5,5);
       printf("Enter any decimal number : ");
       gotoxy(8,8);
       scanf("%d",poctal);

       gotoxy(20,8);
       printf("%o",octal);
       }


   else if(c=='C')
    {
    clrscr();
    phexa=&hexa;

    gotoxy(5,5);
    printf("Enter any decimal number: ");
    gotoxy(8,8);
    scanf("%d",phexa);

    gotoxy(20,8);
    printf("%x",hexa);
    }

   else
    {
    gotoxy(8,11);
    printf("invalid input");
    }

}
//When I'm coding the "would you like to continue?" fails every time. Please guys help me to code it on this last part.



getch();
return 0;
}

Your code doesn't have any continue logic. Could you post the code that "fails every time" so that we can help you fix it?

Edited 3 Years Ago by deceptikon

This article has been dead for over six months. Start a new discussion instead.