A program for Reversing of string

  Reversing of string

 

        In this example, we will understand to do reverse a string in C? What is string reverse function in C? How can you reverse a string? and know how to write, compile and debug it in C language and also learn how to implement it in c.


In order to do this you will need
  • Basic knowledge of c programming language.
  • As well as know how to operate codeblocks.                                                                                                                               

     C does not support strings as a data type.It allows us to represent strings as character arrays.A string variable is any valid C variable name and is always  declared as an array of characters.

The general form of declaration of string variable:
char string_name[size];


Which function is used to reverse a string?
strrev() function:

Description:
This function reverse the given string and stores itself.

Syntax:
strrev(string1);


So let's begin with our program

1.Open a codeblocks software.

2.Open new empty file.

3.Copy and paste the code from below. 




A program for Reversing of string,string,c programming language,basic code,c programming language,2021,basic codes,input output code




Input code- 

//Write a program for Reversing of string.

#include <stdio.h>
#include <string.h>
int main()
{
   char s[100];

   printf("Enter a string to reverse\n");
   gets(s);

   strrev(s);

   printf("Reverse of the string: %s\n", s);

   return 0;
}




Now simply build the code. Look for any error. Now run the code.
For output enter any number or character series you want and press enter key



A program for Reversing of string,string,c programming language,basic code,c programming language,2021,basic codes,input output code



Click the following button to download a program for Reversing of string






Thats it.Thank you for scrolling.






Post a Comment

If you have any doubt or suggestions.please let me know.

Previous Post Next Post

Ads by google

Ads by google