Ok I really need this to fix up. And I've been awake all night just to fix the error. Can you help me with this errors. #1 Binary2Decimal() when I input a binary number it won't give an answer and it will skip the "Decimal Equivalent is: " it will go straight to "Do you want to continue NUMBER CONVERSION?(y/n) ". #2 In my void main() my do while looping is not working because in the "Do you want to continue NUMBER CONVERSION?(y/n) " when everytime I type any y it will exit the program.

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


char value;
char t, u, v;
char answer;

void Binary2Decimal()
       {
       gotoxy(1,13);printf("[BINARY TO DECIMAL CONVERSION]");

       long b2,f2=1,d2=0;
       gotoxy(1,15);printf("Enter a Binary number: ");
       scanf("%d", &b2);

       printf("\n");

       while(b2>0)
       {
       if((b2%10)==1)
       {
       d2=d2+f2;
       }
       b2=b2/10;
       f2=f2*2;
       }
       printf("Decimal equivalent is: ", d2);
       }

void Octal2Decimal()
       {
       gotoxy(1,13);printf("[OCTAL TO DECIMAL CONVERSION]");

       long number4,dec7,rem7,i7,sum7;
       gotoxy(1,15);printf("Enter an Octal number: ");
       scanf("%o", &number4);

       printf("\n");

       dec7=printf("%d", number4);
       {
       rem7=dec7%8;
       sum7=sum7 + (i7*rem7);
       }
       printf("Decimal equivalent is: %d", number4);
       }

void Hexa2Decimal()
       {
       gotoxy(1,13);printf("[HEXADECIMAL TO DECIMAL CONVERSION]");

       long hex,dec8,rem8,i8,sum8;
       gotoxy(1,15);printf("Enter a Hexadecimal number: ");
       scanf("%X", &hex);

       printf("\n");

       dec8=printf("%d", hex);
       {
       rem8=dec8%16;
       sum8=sum8 + (i8*rem8);
       }
       printf("Decimal equivalent is: %d", hex);
       }

    void  main()
     {
      do{
       clrscr();
       gotoxy(1,3);printf("Conversion from any base to base 10");
       gotoxy(1,5);printf("a - Binary");
       gotoxy(1,6);printf("b - Octal");
       gotoxy(1,7);printf("c - Hexadecimal");
       gotoxy(1,11);printf("Select a value to be converted: ");
       scanf("%c", &value);

       switch(value){
       case 'a':
       Binary2Decimal();
       break;
       case 'b':
       Octal2Decimal();
       break;
       case 'c':
       Hexa2Decimal();
       break;
       default:
       printf("Wrong input");
       }

       gotoxy(1,20);printf("Do you want to continue NUMBER CONVERSION?(y/n) ");
       scanf("%c", &answer);
       }

       while(answer=='y');
       getch();

       }

when I input a binary number it won't give an answer

That's because b2 is an integer, binary numbers are character arrays, not integers. If you want to enter a binary number, such as 010101 you have to get it as a string then convert the string to an integer.

If you look down the C++ forum page to the previous thread, you'll see that I gave a detailed answer already.

Would you do us all a favor and not create a new thread each time you log in? It is much easier for everyone if you continue the existing conversations rather than jumping to a new one all over the place. Thank you.

commented: If I didn't know better I would say john.kane ignored you on this one. +5

Ok one more correction in my "void main() the do while loop is not working because everytime I type 'y' it doesn't go in a loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.