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

How can I find leaf node with smallest level in a binary tree?

1 Answers  


C program code int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+zap(n-1); } then the call zap(6) gives the values of zap [a] 8 [b] 9 [c] 6 [d] 12 [e] 15

6 Answers   TCS, Wipro,


How we can set and clear bit in a byte using macro function?

2 Answers   L&T, Samsung,


What is a pointer on a pointer in c programming language?

0 Answers  


what are the languages used in c#?

3 Answers   Infosys,






What does calloc stand for?

0 Answers  


Find the highest of three numbers and print them using ascending orders?

1 Answers  


You have an array of n integers, randomly ordered with value 1 to n-1.The array is such that there is only one and one value occurred twice. How will you find this number?

1 Answers  


Define function ?Explain about arguments?

2 Answers   Geometric Software, Infosys,


What is pragma in c?

0 Answers  


What does emoji p mean?

0 Answers  


what do you mean by defining a variable in our c code?

2 Answers  


Categories