Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to convert binary to hexadecimal

Posted By: Reginhard Fischer     Category: C Programming     Views: 12814

Write a program to convert binary to hexadecimal.

Code for Program to convert binary to hexadecimal in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
    int j=1,i=0;
    int k,num[100],n,sum=0;
    clrscr();
    printf("\n PLEASE ENTER VALUE N:");
    scanf("%d",&n);
    printf("\n PLEASE ENTER IN THE BINARY (0 - 1): ");
    for(k=0;k<n;k++)
    {
    printf("\n\tnum[%d]= ",k+1);
    scanf("%d",&num[k]);
    if(num[k]>1)
    {
        printf("\n YOU ARE NOT ENTER BINARY NUMBER");
        goto end;
    }
    }
    for(k=n-1;k>=0;k--)
    {
        sum=sum+(num[k]*j);
        j=j*16;
    }
    printf("\n BINARY TO HEXADECIMAL CONVERSION IS ");
        printf("%d",sum);
end:
getch();
}
  
Share: 


Didn't find what you were looking for? Find more on Program to convert binary to hexadecimal Or get search suggestion and latest updates.

Reginhard Fischer
Reginhard Fischer author of Program to convert binary to hexadecimal is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!