New file fo Reverse String Using Stack in C

This commit is contained in:
Harshal Jain 2023-10-02 13:15:48 +00:00 committed by GitHub
parent cdc026c81b
commit 3096bb4a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,15 +5,19 @@ int main()
char str[100]; //initialize the string
int top = -1; //give top=-1 so that when first element is scanned index will be 0
int i = 0;
printf("Enter string :- ");
fgets(str,100,stdin); //input of string from the user
fgets(str,100,stdin); //input of string from the user
while(str[i]!='\0')
{
top++;
stack[top] = str[i]; //store each index char of str in stack
i++;
}
i = top; //give i=top so that we can print the string in reverse
printf("\nReverse of the string is :- \n");
while (i != -1)
{