/* 2. WRITE A C PROGRAM TO REVERSE A
NUMBER */
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define MAX 25
void main()
{
char
arr[MAX],temp;
char
*f,*r;
clrscr();
printf("Enter
a Number To Reverse : ");
gets(arr);
f=arr;
r=&arr[strlen(arr)-1];
while(f<r)
{
temp=
*f;
*f=*r;
*r=temp;
f++;
r--;
}
printf("Reversed
string is %s",arr);
getch();
}
/*
=====OUT
PUT=====
1. Enter a Number To Reverse : 0987654321
Reversed string is 1234567890
------------------------------------------
2.
Enter a Number To Reverse : 123321
Reversed string is 123321
*/
0 comments:
Post a Comment