write function to reverse char array ... without using second
array
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
What is strcmp in c?
please tell me the logic for this C program : INPUT (string):ABCD OUTPUT :BCDA CDAB DABC
What are different storage class specifiers in c?
What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file
How can I change their mode to binary?
what is the difference between exit() and _exit() functions?
What is void main () in c?
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
What are the advantages of external class?
change to postfix a/(b+c*d-e)
What is a macro?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?