write a c program to Reverse a given string using string
function and also without string function



write a c program to Reverse a given string using string function and also without string function..

Answer / puneet mittal

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char string[50],reverse[50];
int i,len=0;
printf("Enter the string = ");
gets(string);
strrev(string);
printf("\n reverse of entered string by using string
function : %s",string);
for(i=0;i<50;i++)
{
if(string[i]!='\0')
len++;
}
for(i=0;i<len;i++)
{
reverse[i]==string[len-i];
}
printf("\n\nreverse of entered sting without using
string function :%s ",reverse);
getch();
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Code Interview Questions

write a c program to print magic square of order n when n>3 and n is odd?

1 Answers   HCL,


main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }

1 Answers  


main() { int i=5,j=6,z; printf("%d",i+++j); }

2 Answers  


Is the following code legal? typedef struct a { int x; aType *b; }aType

1 Answers  


int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().

1 Answers  






int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

2 Answers   CSC,


Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique.

5 Answers   IITR, Microsoft, Nike,


In a gymnastic competition, scoring is based on the average of all scores given by the judges excluding the maximum and minimum scores. Let the user input the number of judges, after that, input the scores from the judges. Output the average score. Note: In case, more than two judges give the same score and it happens that score is the maximum or minimum then just eliminate two scores. For example, if the number of judges is 5 and all of them give 10 points each. Then the maximum and minimum score is 10. So the computation would be 10+10+10, this time. The output should be 10 because 30/3 is 10.

0 Answers   TCS,


main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 Answers  


main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }

1 Answers  


Write a complete program that consists of a function that can receive two numbers from a user (M and N) as a parameter. Then print all the numbers between the two numbers including the number itself. If the value of M is smaller than N, print the numbers in ascending flow. If the value of M is bigger than N, print the numbers in descending flow. may i know how the coding look like?

2 Answers  


Categories