Even Position Characters in Reverse Order ID:5395

\

A string S is passed as input. The program must print the characters present at the even positions of the string in reverse order.

Boundary Condition(s):
2 <= Length of String <= 1000

Input Format:
The first line contains the string S.

Output Format:
The first line contains the characters at even positions in reverse order.

Example Input/Output 1:
Input:
independent

Output:
ndeen

Example Input/Output 2:
Input:
computer

Output:
rtpo

Program in C:

#include<stdio.h>

#include<string.h>

int main()

{

char c[1000];

scanf("%s",c);

for(int i=strlen(c)-1;i>=0;i--)

if(i%2!=0) 

printf("%c",c[i]);

}

}

Comments

Popular Posts