Advertisement
Guest User

reverse

a guest
Dec 7th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. #include<string.h>
  4.  
  5.  
  6.  
  7. int main()
  8.  
  9. {
  10.  
  11.   char str1[50]="Sadia Afrin Reme";
  12.  
  13.   char str2[50];
  14.  
  15.   int i=0,len=0,j;
  16.  
  17.   while(str1[i]!='\0')
  18.  
  19.   {
  20.  
  21.     i++;
  22.  
  23.     len++;
  24.  
  25.   }
  26.  
  27.   for(j=0,i=len-1;i>=0;i--,j++)
  28.  
  29.   {
  30.  
  31.     str2[j]=str1[i];
  32.  
  33.   }
  34.  
  35.   str2[j]='\0';
  36.  
  37.  
  38.  
  39.   printf("str1 = %s\n",str1);
  40.  
  41.   printf("str2 = %s\n",str2);
  42.  
  43.  
  44.  
  45.   return 0;
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement