#include<stdio.h>
int main()
{
char a[50];
int l,i=0,j,temp;
printf("Enter a String/Number: ");
gets(a);
for(l=0;a[l]!='\0';l++);
//to determine length of String
j=l-1; // l is the length of String
for(i=0;i<l/2;i++)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
j--;
}
puts(a);
return 0;
Output : Enter a String/Number: 12345
54321
int main()
{
char a[50];
int l,i=0,j,temp;
printf("Enter a String/Number: ");
gets(a);
for(l=0;a[l]!='\0';l++);
//to determine length of String
j=l-1; // l is the length of String
for(i=0;i<l/2;i++)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
j--;
}
puts(a);
return 0;
}
54321
1 Comments
plz provide the code using command line argument
ReplyDelete