in turboc++
----------------------------------------------------------------------------------------------
//WAP to reverse a string using(strrev()) function.Pass string as parameter and return its reverse
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringrev(char string[100]); //function prototype with pointer type. We can avoid it size.
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
printf("reverse=%s\n",stringrev(name));//prints the reversed name by calling the function
getch();
return 0;
}
char *stringrev(char string[100])
{
strrev(string);
return string; //returning its string
}
----------------------------------------------------------------------------------------------
//WAP to reverse a string using(strrev()) function.Pass string as parameter and return its reverse
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringrev(char string[100]); //function prototype with pointer type. We can avoid it size.
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
printf("reverse=%s\n",stringrev(name));//prints the reversed name by calling the function
getch();
return 0;
}
char *stringrev(char string[100])
{
strrev(string);
return string; //returning its string
}
---------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------
//WAP to reverse a string using(strrev()) function.Pass string as parameter and return its reverse
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringrev(char string[100]);
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
printf("reverse=%s\n",stringrev(name));//prints the name
getch();
return 0;
}
char *stringrev(char string[100])
{
strrev(string);
return string;
}
No comments:
Post a Comment