Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@w3Abhishek

w3Abhishek/cpp12 Secret

Created June 6, 2021 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save w3Abhishek/e103cda275f81a0e7e4a2c8174b42578 to your computer and use it in GitHub Desktop.
Save w3Abhishek/e103cda275f81a0e7e4a2c8174b42578 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
char str[1000], rev[1000];
int i, j, count = 0;
printf("Welcome to CodeWin.org!!!\n");
printf("-----------------------\n");
printf("Enter a String: ");
scanf("%s", str);
printf("\nString Before Reverse: %s", str);
//finding the length of the string
while (str[count] != '\0')
{
count++;
}
j = count - 1;
//reversing the string by swapping
for (i = 0; i < count; i++)
{
rev[i] = str[j];
j--;
}
printf("\nString After Reverse: %s", rev);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment