Whenever we are asked to reverse a string, we make use of inbuilt function- strrev (). Obviously, it is the easy method and we can use that. But sometimes, we are asked not to use the strrev (). This program helps to reverse a String without using strrev().
#include <stdio.h>
#include <conio.h>
#include <string.h> // Mandatory to use if we use string’s inbuilt function , here we have use strlen to find length of string
Void main()
{
char string1[10], string2[10];
int i, length;
printf(“Enter any string:\n”);
gets(string1);
length = strlen(string1)-1;
for(i=0; string1[i]!=’\0′; i++)
{
string2[length]=string1[i];
length–;
}
string2[length]=’\0′;
printf(“\nThe Reverse of string is:\n”);
puts(string2);
getch();
}
- MongoDB Operators Tutorial – What are Different Operators Available? - October 5, 2019
- MongoDB Projection Tutorial : Return Specific Fields From Query - March 9, 2019
- MongoDB Index Tutorial – Create Index & MongoDB Index Types - July 6, 2018