Home      Affiliated Colleges      Course content      First Sem     Second Sem     Third Sem     Fourth Sem     Fifth Sem     Sixth Sem     Seventh Sem     Eighth Sem     Lab report 4th sem     Contact    

Wednesday, January 26, 2011

Introduction to Cryptography: C Program to convert Set of Strings to Binary digits:

//String to Ascii
#include<stdio.h>
#include<string.h>
#include<conio.h>
#define MAX 5 //array ko max
#define BINARY 8
void converted(int r,int result[])
{
 int i = 7;
 int rem;
 for(i = 7;i>=0;i--)
 {
   rem = r%2;
   r = r/2;
   result[i] = rem;
 }
}
void main()
 {
   char c,store[MAX];
   int i,j,r,a,result[BINARY];
   clrscr();
   printf("\nEnter any string:");
   scanf("%s",store);
   a=strlen(store);
   for(i=0;i<a;i++)
   {
   r=store[i];
   converted(r,result);
   for(j=0;j<BINARY;j++)
   {
    printf("%d",result[j]);
   }
   printf(" ");
   }
    getch();
 }

No comments:

Post a Comment

^ Scroll to Top Related Posts with Thumbnails ^ Go to Top