Write a program to reverse a string without using library function
Program:
#include<stdio.h> #include<conio.h> void main() { char a[15],temp; int i,j,l=0; printf("enter the string :"); scanf("%s",a); for(i=0;a[i]!='\0';i++) l++; i=0; j=l-1; while(i<j) { temp=a[i]; a[i]=a[j]; a[j]=temp; i++; j--; } printf("reverse string =%s",a); getch(); }
Output:
enter the string :aryan reverse string =nayra
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Program:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer