Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Attempt 1
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- char inp[100]={0}, cdr[]="AAEEIIOOUUAABCDFGHJKLMNPQRSTVWXYZBCaaeeiioouuaabcdfghjklmnpqrstvwxyzbc", ch;
- int c,i,j,len;
- X:
- printf("Enter 1 to Encode\nEnter 2 to Decode\nEnter 0 to Exit\nEnter Your Choice: ");
- scanf("%d",&c);
- if(c==1)
- {
- printf("Enter the Text: ");
- for(i=0 ; 1 ; i++)
- {
- scanf("%c",&ch);
- if(ch=='\n')
- break;
- else
- inp[i]=ch;
- }
- for(i=0 ; i<len ; i++)
- {
- if((inp[i]<65) || (inp[i]>122) || (inp[i]>90 && inp[i]<97))
- printf("%c", inp[i]);
- else
- for(j=0 ; j<64 ; j++)
- if(inp[i]==cdr[j])
- {
- printf("%c",cdr[j+2]);
- break;
- }
- }
- printf("\n");
- goto X;
- }
- else if(c==2)
- {
- printf("Enter the Text: ");
- for(i=0 ; ch!='\n' ; i++)
- {
- scanf("%c",&ch);
- if(ch!='\n') inp[i]=ch;
- }
- for(i=0 ; i<len ; i++)
- {
- if((inp[i]<65) || (inp[i]>122) || (inp[i]>90 && inp[i]<97))
- printf("%c", inp[i]);
- else
- for(j=2 ; j<68 ; j++)
- {
- if(j==35)
- j=37;
- if(inp[i]==cdr[j])
- {
- printf("%c",cdr[j-2]);
- break;
- }
- }
- }
- printf("\n");
- goto X;
- }
- else if(c==0)
- goto Z;
- else
- {
- printf("Wrong input. Try Again\n\n");
- goto X;
- }
- Z:
- return 0;
- }
- //Attempt 2
- #include<stdio.h>
- #include<string.h>
- void gete(char *i)
- {
- char inp[100];
- int len, j;
- gets(inp);
- len=strlen(inp);
- for(j=0; j<=len ; j++)
- *(i+j)=inp[j];
- return;
- }
- int main()
- {
- char inp[100]={0}, cdr[]="AAEEIIOOUUAABCDFGHJKLMNPQRSTVWXYZBCaaeeiioouuaabcdfghjklmnpqrstvwxyzbc", ch;
- int c,i,j,len;
- X:
- printf("Enter 1 to Encode\nEnter 2 to Decode\nEnter 0 to Exit\nEnter Your Choice: ");
- scanf("%d",&c);
- if(c==1)
- {
- printf("Enter the Text: ");
- gete(&inp);
- /* for(i=0 ; 1 ; i++)
- {
- scanf("%c",&ch);
- if(ch=='\n')
- break;
- else
- inp[i]=ch;
- }
- */
- for(i=0 ; i<len ; i++)
- {
- if((inp[i]<65) || (inp[i]>122) || (inp[i]>90 && inp[i]<97))
- printf("%c", inp[i]);
- else
- for(j=0 ; j<64 ; j++)
- if(inp[i]==cdr[j])
- {
- printf("%c",cdr[j+2]);
- break;
- }
- }
- printf("\n");
- goto X;
- }
- else if(c==2)
- {
- printf("Enter the Text: ");
- for(i=0 ; ch!='\n' ; i++)
- {
- scanf("%c",&ch);
- if(ch!='\n') inp[i]=ch;
- }
- for(i=0 ; i<len ; i++)
- {
- if((inp[i]<65) || (inp[i]>122) || (inp[i]>90 && inp[i]<97))
- printf("%c", inp[i]);
- else
- for(j=2 ; j<68 ; j++)
- {
- if(j==35)
- j=37;
- if(inp[i]==cdr[j])
- {
- printf("%c",cdr[j-2]);
- break;
- }
- }
- }
- printf("\n");
- goto X;
- }
- else if(c==0)
- goto Z;
- else
- {
- printf("Wrong input. Try Again\n\n");
- goto X;
- }
- Z:
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement