write function to reverse char array ... without using second
array

Answers were Sorted based on User's Feedback



write function to reverse char array ... without using second array..

Answer / nagesh r. dalave

void main()
{
char strp20];
int len=0,i=0;
printf("\nEnter a string ");
gets(str);
while(str[i]!='\0')
{
i++;
len++;
}
printf("\nReverse of given string:");
while(i>=0)
{
printf("\n %c",str[i]);
i--;
}
getch();
}

Is This Answer Correct ?    3 Yes 0 No

write function to reverse char array ... without using second array..

Answer / kiran

{
char temp;
for(i,j=strlen(str)-1;i<j;i++,j--)
{
temp = str[i];
str[i] = str[j];
str[j] = temp;
}
return str;
}

Is This Answer Correct ?    0 Yes 0 No

write function to reverse char array ... without using second array..

Answer / sunitha

/* function to reverse a charactor array */

void rev_array(char str[])
{
char c;
char *p;
p=str;
while(*p)
{
if(*p!='\0')
{
c=p;
}
p++;
}
printf("reverse array is %s\n",c);
}

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More C Interview Questions

Do variables need to be initialized?

0 Answers  


what is the output of following question? void main() { int i=0,a[3]; a[i]=i++; printf("%d",a[i] }

3 Answers  


wat is the meaning of c?

9 Answers   CTS, IBM, Wipro,


int a[3][5]={ {1,2,3,4,5],{2,3,4,5,6},{10,11,12,13,14}}; int *p=&a; printf(“%d”,*(*(x+1)+3));

2 Answers   Wipro,


Is c++ based on c?

0 Answers  


Differentiate abs() function from fabs() function.

0 Answers  


I heard that you have to include stdio.h before calling printf. Why?

0 Answers  


When do we get logical errors?

0 Answers  


Why doesnt this code work?

0 Answers  


write a program for fibonaci series by using while loop in c?

2 Answers  


what is the different between data structure and data type?

1 Answers   Ignou,


Is struct oop?

0 Answers  


Categories