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 |
A marketing company wishes to construct a decision table to decide how to treat clients according to three characteristics: Gender, City Dweller, and age group: A (under 30), B (between 30 and 60), C (over 60). The company has four products (W, X, Y and Z) to test market. Product W will appeal to female city dwellers. Product X will appeal to young females. Product Y will appeal to Male middle aged shoppers who do not live in cities. Product Z will appeal to all but older females.
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What is a function in c?
WHAT IS FLOAT?
What is the output of following program ? int main() { int x = 5; printf("%d %d %d\n", x, x << 2, x >> 2); }
Where we use clrscr in c?
what is available in C language but not in C++?
10 Answers CTS, TCS,
What are extern variables in c?
Does sprintf put null character?
how can you print&scan anything using just one character? :) HINT: printf,scanf similer
What is wrong in this statement? scanf(“%d”,whatnumber);
How to draw the flowchart for structure programs?