-->

WAP to reverse a string using(strrev()) function.

using turbo c++
-------------------------------------------
//WAP to reverse a string using(strrev()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char name[100];//two dimensional declaration
    printf("enter string\n");
    //fgets(name, sizeof (name), stdin);
    scanf("%[^\n]s",name); //it also CAN BE USED. IT accepts string with space until it meets new line
    strrev(name);
    printf("reverse=%s\n",name);//prints the name
     getch();
    return 0;
}
-------------------------------------------------
in codeblocks
------------------------------------------------------
//WAP to reverse a string using(strrev()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char name[100];//two dimensional declaration
    printf("enter string\n");
    //fgets(name, sizeof (name), stdin);
    scanf("%[^\n]s",name); //it also CAN BE USED. IT accepts string with space until it meets new line
    strrev(name);
    printf("reverse=%s\n",name);//prints the name
    return 0;
}

No comments:

Post a Comment