Wednesday, 28 August 2013

Read characters from the standard input/file and replace each character by the next character in the ASCII sequence. E.g., replace 'a' by 'b', 'z' by 'a'.

 #include<stdio.h>
#include<string.h>
int main(){
  char str[20];
  int i;
  printf("Enter any string->");
  scanf("%s",str);
  printf("The string is->%s",str);
  for(i=0;i<=strlen(str);i++){
      if(str[i]>=97&&str[i]<=121)
       str[i]=str[i]+1;
      else if(str[i]==122)
       str[i]=str[i]-25;
  }
  printf("\nThe string in lower case is->%s",str);
  return 0;
}

No comments:

Post a Comment