1.Write a program to reverse an array or string
Given an array (or string), the task is to reverse the array/string.
Examples :
Input : arr[] = {1,2,3,4,5,6}
Output : arr[] = {6,5,4,3,2,1}
Input : arr[] = {p,r,o,g,r,a,m}
Output : arr[] = {m,a,r,g,o,r,p}
strrev(arr)
ReplyDeletetry to implement the logic bro, don't use predefined function
Delete
ReplyDelete1. function for reverse the string but if we have to reverse the number then we have to change the datatype of array and logic is same
void reverseString(char* s, int sSize){
int t;
for(int j=0,i=sSize-1;j<i;j++,i--)
{
t=s[j];
s[j]=s[i];
s[i]=t;
}
}
right dear
Delete