Program To Accept A Line Of Text Into A String Array And Then Encrypt The Contents Of The Array
/* Program To Accept A Line Of Text Into A String Array And Then Encrypt The Contents Of The Array As Given Below Encryption __________ a -> b | A -> B | 0 ->1 b -> c | B -> C | 1 -> 2 c -> d | C -> D | 2 -> 3 | | | | | | | | | | z -> a | Z -> A | 9 -> 0 DISPLAY THE TEXT AFTER ENCRYPTION AND THEN DECRYPT THE CONTENTS OF THE ARRAY AS GIVEN BELOW DECRYPTION ___________ a <- b | A <- B | 0 <- 1 b <- c | B <- C | 1 <- 2 | | | | | | | | | | z <- a | Z <- A | 9 <- 0 DISPLAY THE TXET AFTER DECRYPTION */ #include
#include
void main() { char text[100]; int i; clrscr(); printf("\n enter a line of text(EOF to stop..) \n"); gets(text); for( i=0;text[i]!='\0';i++ ) { if( isalpha (text[i]) ) { if( text[i]=='z' ) text[i]='a'; else if ( text[i]=='Z' ) text[i]='A'; else text[i]=text[i]+1; } else if( text[i]) { if( text[i]=='9' ) text[i]='\0'; else text[i]=text[i]+1; } printf("\n after encrytion \n %s",text); for( i=0;text[i]!='\0';i++ ) { if( isalpha(text[i]) ) { if ( text[i]=='a' ) text[i]='z'; else if( text[i]=='A' ) text[i]='Z'; else text[i]=text[i]-1; } else if( isdigit( text[i]) ) { if( text[i]=='\0' ) text[i]='9'; else text[i]=text[i]-1; } } printf("\n after decrytion \n %s",text); getch(); }
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/