Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Strange Photos Academic Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter




C Program of reversing a string using stack


Posted Date: 24 Mar 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: ashish singh       Member Level: Diamond
Rating:     Points: 2



/* Program of reversing a string using stack */
#include
#define MAX 20
#include

int top = -1;
char stack[MAX];
char pop();
push(char);
main()
{
char str[20];
int i;
printf("Enter the string : " );
gets(str);
/*Push characters of the string str on the stack */
for(i=0;i push(str[i]);
/*Pop characters from the stack and store in string str */
for(i=0;i str[i]=pop();
printf("Reversed string is : ");
puts(str);
}/*End of main()*/

push(char item)
{
if(top == (MAX-1))
printf("Stack Overflow\n");
else
stack[++top] =item;
}/*End of push()*/

char pop()
{
if(top == -1)
printf("Stack Underflow\n");
else
return stack[top--];
}/*End of pop()*/




Responses

Author: Prasad    10 Aug 2008Member Level: Gold   Points : 0
Excellence in technical education and research


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: C Program of queue using linked list
Previous Resource: C Program of sparse matrix for 3-tuple method using array
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources

Watch TV Channels



Contact Us    Editors    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.