Programming Concepts Question:

Write a C program to reverse the string without using strrev() function?

Programming Concepts Interview Question
Programming Concepts Interview Question

Answer:

#include <stdio.h>
#include <conio.h>
#include <string.h>

void main()
{
char *str;
int i,len;

//not using any temp variable and assume we can use only string array and length

printf("Enter String : ");
scanf("%s",str);
len=strlen(str)-1;
for(i=0;i<strlen(str)/2;i++)
{
str[i]+=str[len];
str[len]=str[i]-str[len];
str[i]=str[i]-str[len--];
}
printf("Reverse String is : %s",str);
getch();
}


Previous QuestionNext Question
Explain difference between computer architecture, structure, and organization?Tell me how to execute 13,000 test cases in a faster way in manual testing?