<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stacks using array | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/stacks-using-array/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sun, 10 Jun 2012 10:14:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C Program for implementing two Stacks on Single Array</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-implementing-two-stacks-on-single-array/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-implementing-two-stacks-on-single-array/#comments</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 17:08:14 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[Stacks using array]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3336</guid>

					<description><![CDATA[<p>C Program for implementing two Stacks on Single Array. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #define SIZE 10 /* Size of Stack */ int s[SIZE],top[3]={0,-1,SIZE}; /* Global declarations */ push(int elem,int stno) { int pos; /* Function for PUSH operation */ if( Sfull()) printf("\n\n Overflow!!!!\n\n"); else { if(stno==1) pos=</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-implementing-two-stacks-on-single-array/">C Program for implementing two Stacks on Single Array</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program for implementing two Stacks on Single Array.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#define SIZE 10            /* Size of Stack */
int s[SIZE],top[3]={0,-1,SIZE};
/* Global declarations */
push(int elem,int stno)
{
    int pos;	     /* Function for PUSH operation */
    if( Sfull()) printf("\n\n Overflow!!!!\n\n");
    else
    {
        if(stno==1) pos= ++top[stno];
        else pos=--top[stno];
        s[pos]=elem;
    }
}

int pop(int stno)
{                      /* Function for POP operation */
    int elem,pos;
    if(Sempty(stno)){ printf("\n\nUnderflow!!!!\n\n");
    return(-1); }
    else
    {
        pos=top[stno];
        elem=s[pos];
        if(stno == 1)top[stno]--;
        else
            top[stno]++;
        return(elem);
    }
}

int Sfull()
{                     /* Function to Check Stack Full */
    if(top[1] == top[2]-1) return 1;
    return 0;
}

int Sempty(stno)
{
    /* Function to Check Stack Empty */
    switch(stno)
    {
    case 1: if(top[1] == -1) return 1; else return 0;
    case 2: if(top[2] == SIZE) return 1;else return 0;
    }
}

display(int stno)
{                  /* Function to display status of Stack */
    int i;
    if(Sempty(stno)) printf(" \n Empty Stack\n");
    else
    {
        if(stno == 1)
        {
            for(i=0;i<=top[stno];i++)
                printf("%d\n",s[i]);
            printf("^Top");
        }
        else
        {
            for(i=SIZE-1;i>=top[stno];i--)
                printf("%d\n",s[i]);
            printf("^Top");
        }
    }
}

main()
{                         /* Main Program */
    int opn,elem,stno;
    do
    {
        clrscr();
        printf("\n ### Stack Operations ### \n\n");
        printf("\n Stack Number (1,2): ");
        scanf("%d",&stno);
        printf("\n Press 1-Push, 2-Pop,3-Display,4-Exit\n");
        printf("\n Your option ? ");
        scanf("%d",&opn);

        switch(opn)
        {
        case 1: printf("\n\nRead the element to be pushed ?");
            scanf("%d",&elem);
            push(elem,stno); break;
        case 2: elem=pop(stno);
            if( elem != -1)
                printf("\n\nPopped Element is %d \n",elem);
            break;
        case 3: printf("\n\nStatus of Stack %d \n\n",stno);
            display(stno); break;
        case 4: printf("\n\n Terminating \n\n"); break;
        default: printf("\n\nInvalid Option !!! Try Again !! \n\n");
            break;
        }
        printf("\n\n\n\n  Press a Key to Continue . . . ");
        getch();
    }while(opn != 4);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-implementing-two-stacks-on-single-array/">C Program for implementing two Stacks on Single Array</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-implementing-two-stacks-on-single-array/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
