Write a program to read a string and print all the characters in the reverse order using pointers (Not using arrays).

Leave a Comment
#include<sdtio.h>
#include<conio.h>


int main()
{
char a[100],*c;
int n,i;
printf("\nEnter the string length:");
scanf("%d",&n);
c=a;
printf("\nNow intput the string\n");
for(i=0;i<n;i++)

{
*c++=getche();
}
printf("\nPrinting the string u entered in reverse we get\n");

for(i=0;i<n;i++)

{
printf("%c",*c--);
}
getche();
return 0;
}

0 comments: