STRREV :
This funcion inputs an array(string) from user and outputs its reverse order.
#include <stdio.h>
using namespace std;
void strrev(char []);
int strlen(char []);
int main()
{
char arr[200];
cout<<"Enter any statement to get its reverse. "<<endl;
gets(arr);
cout<<"After Being reversed : "<<endl;
strrev(arr);
return 0;
}
void strrev(char array[])
{
int length,i;
length = strlen(array)-1;
char array1[length];
for(i=0 ; array[i]!='\0' ; i++)
{
array1[length]=array[i];
length--;
}
array1[length]='\0';
cout<<array1;
}
int strlen(char array[])
{
int sum=0;
for(int i=0 ; array[i]!='\0' ; i++)
{
sum+=1;
}
return sum;
}
This funcion inputs an array(string) from user and outputs its reverse order.
Here is the Code: >>>
#include <iostream>#include <stdio.h>
using namespace std;
void strrev(char []);
int strlen(char []);
int main()
{
char arr[200];
cout<<"Enter any statement to get its reverse. "<<endl;
gets(arr);
cout<<"After Being reversed : "<<endl;
strrev(arr);
return 0;
}
void strrev(char array[])
{
int length,i;
length = strlen(array)-1;
char array1[length];
for(i=0 ; array[i]!='\0' ; i++)
{
array1[length]=array[i];
length--;
}
array1[length]='\0';
cout<<array1;
}
int strlen(char array[])
{
int sum=0;
for(int i=0 ; array[i]!='\0' ; i++)
{
sum+=1;
}
return sum;
}
No comments:
Post a Comment