how to reverse string "Hello World" by using pointers only.
Without any temp var

Answer Posted / aravind

#include<stdio.h>
char reverse(char *, char *);
int main()
{
char a[]="hello"
char b[]="world";
gets(a,b);
puts(a); /*displays Hello world*/
reverse(a,b);

char reverse(char *ptr, char *ptr1)
{
int i,j;
for(i=0;i!='\0';i++)
{
printf("%s",*ptr);
ptr++;
}
for(j=0;j!='\0';j++)
{
printf("%s",*ptr1);
ptr1++;
}
gets(*ptr1,*ptr);
puts(*ptr1); /*displays world hello*/
}

Is This Answer Correct ?    0 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the valid places to have keyword “break”?

655


Which is best book for data structures in c?

601


There seem to be a few missing operators ..

621


What is the best organizational structure?

644


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

567






Subtract Two Number Without Using Subtraction Operator

360


In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.

2686


The __________ attribute is used to announce variables based on definitions of columns in a table?

675


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1524


What is the easiest sorting method to use?

637


What is a static function in c?

626


Is null equal to 0 in sql?

657


Write a program to print "hello world" without using a semicolon?

600


What is the maximum no. of arguments that can be given in a command line in C.?

674


What are the different file extensions involved when programming in C?

764