This is a program to reverse a string without the string.h header. If you have any doubts, please do ask.
#include<stdio.h>
main()
{
int i,count=0,j=0;
char string[10],final[10];
scanf("%s",string);
for(i=0;string[i]!='\0';i++)
count++;
count--;
for(i=count;i>=0;i--)
{
final[j]=string[i];
j++;
}
final[j]='\0';
printf("%s",final);
}
#include<stdio.h>
main()
{
int i,count=0,j=0;
char string[10],final[10];
scanf("%s",string);
for(i=0;string[i]!='\0';i++)
count++;
count--;
for(i=count;i>=0;i--)
{
final[j]=string[i];
j++;
}
final[j]='\0';
printf("%s",final);
}
No comments:
Post a Comment