Tuesday, 29 July 2014

5. A. WRITE A MENU DRIVEN C PROGRAM TO A. ACCEPT A STRING FROM THE USER B. ENCODE THE STRING. C. DECODE THE STRING



5. A. WRITE A MENU DRIVEN C PROGRAM TO
A. ACCEPT A STRING FROM THE USER
B. ENCODE THE STRING.
C. DECODE THE STRING
APPLY THE FOLLOWING PROCEDURE TO ENCODE IT.
1. CONVERT EACH CHARACTER IN A STRING TO ITS ASCI VALUE.
2. ADD AN INTEGER VALUE TO IT AND DISPLAY THE ENCODED STRING
3. DECODE THE STRING USING REVERSE PROCEDURE AND DISPLAY.
SOURCE CODE:
#include <stdio.h>
void main()
{
char name[100],i;
printf("Enter String: ");
scanf("%s",name);
for(i=0;i<strlen(name);i++)
{
name[i]=name[i]+5;
}
for(i=0;i<strlen(name);i++)
{
printf("String after encoding(ASCII+5)\n");
for(i=0;i<strlen(name);i++)
printf("%d\n",name[i]);
}
for(i=0;i<strlen(name);i++)
{
name[i]=name[i]-5;
}
printf("String after Decoding\n");
printf("%s",name);
}

0 comments:

Post a Comment

 
- |