Subscribe to Get Free Material Updates!
Visit my new blog WebData Scraping - Web Scraping Service provider company in India.

Write a Program to convert the ASCII to binary & Binary to ASCII


#include<stdio.h>
#include<stdio.h>
#include<ctype.h>
#include<math.h>
int main()
{
 int a,q,i=0,j,ans=0;
 int arr[10];
 char c;
 clrscr();
 printf("\n Enter any character :");
 scanf("%c",&c);
 a=toascii(c);
 q=a;
 printf("\n\n%d",q);
 while(q!=1)
 {
  arr[i]=q%2;
  q/=2;
  i++;
 }
 arr[i]=1;
 printf("\nAscii To Binary..\n");
 for(j=i;j>=0;j--)
  printf("%d",arr[j]);
 for(j=i;j>=0;j--)
 {
  if(arr[j]==1)
   ans+=pow(2,j);
 }
 printf("\n Binary to Ascii..%d & Char .. %c\n",ans,ans);
return 0;
}

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes