Contact Learn C
Copy

Program 214:Encryption using Latin Alphabet in C

Program 214:
 
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
main()
{
//In this A-1,B-2....Z-26
//a-1,b-2,...z-26
 int i;
 char str[1000];
 printf("Enter a sentence\n");
 gets(str); 
 i=0;
 while(str[i]!='\0')
 {
  if((str[i]>=0&&str[i]<=31)||(str[i]>=33&&str[i]<65)||(str[i]>90&&str[i]<97)||(str[i]>122&&str[i]<=127))
  {
   printf("Enter only alphabets and space\n");
   exit(0);
  }
  i++;
 }
 i=0;
 printf("Encrypted Code using Latin Alphabet\n");
 while(str[i]!='\0')
  {
 if(!((str[i]>=0&&str[i]<=31)||(str[i]>=33&&str[i]<65)||(str[i]>90&&str[i]<97)||(str[i]>122&&str[i]<=127)))
 {
   if(str[i]>='A'&&str[i]<='Z')
   printf("%d ",str[i]-'A'+1);
   if(str[i]>='a'&&str[i]<='z')
   printf("%d ",str[i]-'a'+1);
 } 
    
    if(str[i]==' ')
    {
      printf("%c",str[i]);    
    }
    
   i++;
  }
  printf("\n");
 
}


Explanation:

//Coming Soon

Output:

Latin Alphabet Encryption


 
Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide