CrazyEngineers
  • coding problem

    Deitel

    Member

    Updated: Oct 25, 2024
    Views: 1.3K
    pls can some one tell me this code is giving errors when i run it..??
    Decimal to Binary, Octal and HEX converter

    #include<stdio.h>
    #include<conio.h>
    #define MAX 79
    #define ESC 27
    void main()
    {
    char res,r;
    int i,k=0,y;
    long j=0,l=0,o=0;
    textcolor(15);
    for(i=0;i<5000;i++)
    cprintf(" ");
    while(1)
    {
    clrscr();
    printf("Enter Any Number To Be Converted : ");
    scanf("%ld",&j);
    l=j;
    o=l;
    k=0;
    if(j>2145555550)
    {
    textcolor(4);
    gotoxy(15,5);
    cprintf("The Number Is Greater Than Range");
    textcolor(15);
    getch();
    goto end;
    }
    else
    {
    gotoxy(1,6);
    printf("Binary Equivalent:-");
    y=MAX;
    while(j>0)
    {
    k=j%2;
    j=j/2;
    gotoxy(y,6);
    y--;
    printf("%d",k);
    }
    gotoxy(1,8);
    printf("Hexadecimal Equivalent:- ");
    y=MAX;
    while(l>0)
    {
    k=l%16;
    l=l/16;
    gotoxy(y,8);
    y--;
    if(k<=9)
    {
    printf("%d",k);
    }
    if(k==10)
    {
    printf("A");
    }
    if(k==11)
    {
    printf("B");
    }
    if(k==12)
    {
    printf("C");
    }
    if(k==13)
    {
    printf("D");
    }
    if(k==14)
    {
    printf("E");
    }
    if(k==15)
    {
    printf("F");
    }
    }
    gotoxy(1,10);
    printf("Octal Equivalent:- ");
    y=MAX;
    while(o>0)
    {
    k=o%8;
    o=o/8;
    gotoxy(y,10);
    y--;
    printf("%d",k);
    }
    }
    gotoxy(15,25);
    printf("Press Any Key To Continue , ESC To Exit");
    res=getch();
    if(res==ESC)
    {
    break;
    }
    }
    end:
    textcolor(7);
    for(i=0;i<5000;i++)
    cprintf(" ");
    clrscr();
    }
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • PraveenKumar Purushothaman

    MemberMay 15, 2011

    No Error and No Output... I guess there's something wrong in your program. Can you please code them inside the code tags???
    Are you sure? This action cannot be undone.
    Cancel
  • vinsocorp

    MemberMay 23, 2011

    No error in your program..there is some logical error happened in your code..
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 24, 2011

    It is going in a continuous loop I guess...
    Are you sure? This action cannot be undone.
    Cancel
  • Prasad Ajinkya

    MemberMay 24, 2011

    I am not running this program, however, could you -
    1. start using switch instead of the multiple ifs
    2. stop using while(1) and put your getch() condition in the while
    3. get rid of the fancy colors and formatting. work on the functionality first, then make it look good
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberJun 1, 2011

    it is working fine on my PC
    there is no error appearing
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberJun 1, 2011

    Manish, are you getting the desired output?
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberJun 1, 2011

    yeah i am getting desired output
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register