Sunday 28 April 2013

C Program to Print a given String in Reverse order Using Pointers

By

Write a C Program to Reverse a String Using Pointers


Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char str[100];
char *strp,l;
int i;
printf("**************************");
printf("\nwww.flintgroups.com\n");
printf("**************************\n");
printf("Enter a String\n");
gets(str);
printf("The Reversed String is : ");
l=strlen(str);
strp=&str[l];
for(i=0;i<=l;i++)
{
printf("%c",*strp);
strp--;
}
getch();
}


Output

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Labels