Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(C programing) Need hep for my lab peoblem. (a) Write a program that reverses st

ID: 3681558 • Letter: #

Question

(C programing) Need hep for my lab peoblem.

(a) Write a program that reverses strings
You need to define a function called string_reverse () that accepts a string as an argument and reverses the string without creating an extra array to perform the reversing, i.e. "class 200 is cool!" becomes "!looc si 002 ssalc". This is a form of in place reversal. The function should return a pointer to the reversed string. Implement a solution to this function using array notation only.

NOTE: you may NOT use any <string.h> library functions to solve this problem!

Explanation / Answer

#include<stdio.h>

#include<string.h>

string_reverse(char *string)
{
int left,right,len=strlen(string);
char *str;
if(len==0)
return 0;
left=0;
right=len-1;
while(right>=0)
{
   str[left]=string[right];
   left++;
   right--;
   }
   str[left]='';
   return str;
   }
main()
{
char string[40];
clrscr();
printf("****Program to test if the given string is in reverse**** ");
printf("Enter a string:");
scanf("%s",string);
printf("the given string is %s ",string);