Write the Program to reverse a string using pointers.



Write the Program to reverse a string using pointers...

Answer / Satyam Tiwari

"```n#include <stdio.h>nnvoid reverse(char* str)n{n char * start = str;n char * end = str + strlen(str) - 1;nn while (start < end)n {n char temp = *start;n *start = *end;n *end = temp;nn start++;n end--;n }n}nnint main()n{n char str[100];n printf("Enter a string: ");n scanf("%s", &str);n reverse(str);n printf("Reversed string is: %s", str);n return 0;n}n```"

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Design a program using an array that lists even numbers and odd numbers separately from the 12 numbers supplied by a user.

8 Answers  


What is wrong with this declaration?

1 Answers  


Find Index of least significant bit set in an Integer. ex. int value is say 10001000 results should be 4.

1 Answers  


read an array and search an element

1 Answers  


How can you find the day of the week given the date?

1 Answers  


What is malloc calloc and realloc in c?

1 Answers  


What is c programming structure?

1 Answers  


When a c file is executed there are many files that are automatically opened what are they files?

1 Answers  


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} what would be the output?

1 Answers   Wipro,


How can I call fortran?

1 Answers  


write a c program that if the given number is prime, and their rearrangement(permute) of that number is also prime. Ex: Input is "197" is prime Output: 791,917,179 is also prime. Please any one tell me tha code for that

3 Answers  


sum of two integers values only other then integer it should print invalid input.

1 Answers  


Categories