Print Alternate Characters From String

  1. #include<stdio.h>  
  2. #include<conio.h>  
  3. #include<string.h>  
  4. main()  
  5. {  
  6.     // print alternate characters from given string  
  7.     char s1[250], s2[250];  
  8.     int i = 0, length, j=0;  
  9.     printf("please enter string\n");  
  10.     gets(s1);  
  11.     length = strlen(s1);  
  12.     while(i<length)  
  13.     {  
  14.         s2[j]=s1[i];  
  15.         i=i+2;  
  16.         j=j+1;   
  17.     }  
  18.     s2[j]='\0';  
  19.     printf("alternate character is:\n");  
  20.     puts(s2);  
  21.     getch();