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    

Monday, August 9, 2010

Introduction to Cryprography: Write a program to display ASCII values of the entered string.


Program:
#include<stdio.h>
#include<string.h>
#include<conio.h>

#define MAX 5
#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:");
                         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