English, asked by ashakandula, 4 months ago

String Challenge
Have the function String Challenge (str)
take the str parameter being passed and
return the string in reversed order. For example:
if the input string is "Hello World and Coders"
then your program should return the string
sredoc dna dlrow olleH.
Examples
Input: "coderbyte
Output: etybredoc
Input. "I Love Code
Output: edoc evol I​

Answers

Answered by mad210203
12

Program is given below.

Explanation:

#include <stdio.h>

void String_Challenge(char str[]);

int main()

{

   char string[100],reverse[100];

   printf("Enter a string: \n");

   gets(string);

   String_Challenge(string);

   return 0;

}

void String_Challenge(char str[])

{

char temp[100];

int i,length;

for (length = 0; str[length] != '\0'; ++length)

{

}

printf("Length of the string: %d\n", length);

   

for(i=0;i<length;i++)

temp[i]=str[length-1-i];

   for(i=0;i<length;i++)

str[i]=temp[i];

    printf("Reverse of the given string is: %s",str);

}

Refer the attached image for the output.

Attachments:
Similar questions