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



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

Answer / 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

More C Interview Questions

Write a program to print factorial of given number using recursion?

0 Answers  


What is #line used for?

0 Answers  


What is the use of a static variable in c?

0 Answers  


Place the #include statement must be written in the program?

0 Answers  


Write a C program to perform some of the operation which can be performed using Single linked list

1 Answers   Qualcomm,


Difference between macros and inline functions? Can a function be forced as inline?

0 Answers   HAL, Honeywell, Zomato,


Explain the differences between public, protected, private and internal.

2 Answers  


Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers

0 Answers  


Given an array of characters, how would you reverse it? How would you reverse it without using indexing in the array?

1 Answers   Microsoft,


When should a type cast not be used?

0 Answers  


hi any body pls give me company name interview conduct "c" language only

0 Answers  


What are the 5 organizational structures?

0 Answers  


Categories