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 |
Do variables need to be initialized?
what is the output of following question? void main() { int i=0,a[3]; a[i]=i++; printf("%d",a[i] }
wat is the meaning of c?
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));
Is c++ based on c?
Differentiate abs() function from fabs() function.
I heard that you have to include stdio.h before calling printf. Why?
When do we get logical errors?
Why doesnt this code work?
write a program for fibonaci series by using while loop in c?
what is the different between data structure and data type?
Is struct oop?