Given an array of characters, how would you reverse it? How
would you reverse it without using indexing in the array?
Answer / abdur rab
#include <stdio.h>
void reverse ( char* cp_str )
{
char* cp_rev_ptr = NULL;
cp_rev_ptr = cp_str;
while ( ( cp_rev_ptr ) && ( *cp_rev_ptr != '\0' ) )
cp_rev_ptr++;
cp_rev_ptr--;
while ( cp_str < cp_rev_ptr ) {
*cp_str ^= *cp_rev_ptr ^= *cp_str ^=
*cp_rev_ptr;
cp_str++;
cp_rev_ptr--;
}
}
int main ( int argc, char* argv [] )
{
char array [] = {"dlroW olleH"};
printf ("\nBefore :%s", array );
reverse ( array );
printf ("\nAfter :%s", array );
return ( 0 );
}
Output
======
Before :dlroW olleH
After :Hello World
Is This Answer Correct ? | 16 Yes | 5 No |
Why is sprintf unsafe?
Are negative numbers true in c?
write a program to gat the digt sum of a number (et. 15= >1+5=6)
What are nested functions in c?
what is the difference between malloc() and calloc() function?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
Differentiate between new and malloc(), delete and free() ?
What is difference between structure and union in c?
1. Write the function int countchtr(char string[ ], int ch); which returns the number of times the character ch appears in the string. Example, the call countchtr(“She lives in NEWYORK”, ‘e’) would return 3.
what is data structure.in linear and non linear data structures which one is better?Explain
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
What is sizeof array in c?