-->

Write a program to reverse a a string using function. Use no arguments and return value

in turboc++
----------------------------------------------------------------------------------

// program to reverse a string          // title of program
#include<stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
char  *string_reverse();                       // function prototype
int main()                                  // main function returning integer value
{
    printf("reverse=%s",string_reverse());                       // function calling with output
    return 0;                              // returning value 0
}
char *string_reverse()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string\n");                   // message declaration
  gets(string);                           // gets string from user

 return strrev(string);                     //returns string

}

----------------------------------------------------------------------------
using codeblocks:
----------------------------------------------------------------------------------------------

// program to reverse a string          // title of program
#include<stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
char  *string_reverse();                       // function prototype
int main()                                  // main function returning integer value
{
    printf("reverse=%s",string_reverse());                       // function calling with output
    return 0;                              // returning value 0
}
char *string_reverse()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string\n");                   // message declaration
  gets(string);                           // gets string from user
 
 return strrev(string);                     //returns string

}

No comments:

Post a Comment