<?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>C Programs | Student Projects</title>
	<atom:link href="https://studentprojects.in/category/software-development/c-tutorials/c/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 10 Mar 2022 07:40:26 +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>Least Recently Used Paging Algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/c-advanced/least-recently-used-paging-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/c-advanced/least-recently-used-paging-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Arun]]></dc:creator>
		<pubDate>Wed, 17 Apr 2013 09:38:52 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[LRU]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=4033</guid>

					<description><![CDATA[<p>Least Recently Used Paging Algorithm #include "stdio.h" #include "conio.h" int fr[3]; void main() { void display(); int p[20]={1,0,7,1,0,2,1,2,3,0,3,2,4,0,3,0,2,1,0,7},i,j,fs[3]; int index,k,l,flag1=0,flag2=0,pf=0,frsize=3; clrscr(); for(i=0;i&#60;3;i++) { fr[i]=-1; } for(j=0;j&#60;20;j++) { flag1=0,flag2=0; for(i=0;i&#60;3;i++) { if(fr[i]==p[j]) { flag1=1; flag2=1; break; } } if(flag1==0) { for(i=0;i&#60;3;i++) { if(fr[i]==-1) { fr[i]=p[j]; flag2=1; break; } } } if(flag2==0) { for(i=0;i&#60;3;i++) fs[i]=0; for(k=j-1,l=1;l&#60;=frsize-1;l++,k--) {</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-advanced/least-recently-used-paging-algorithm/">Least Recently Used Paging Algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Least Recently Used Paging Algorithm</p>
<pre lang="C" line="1">#include "stdio.h"
#include "conio.h"
int fr[3];
void main()
{
	void display();

	int p[20]={1,0,7,1,0,2,1,2,3,0,3,2,4,0,3,0,2,1,0,7},i,j,fs[3];
	int index,k,l,flag1=0,flag2=0,pf=0,frsize=3;
	clrscr();
	for(i=0;i&lt;3;i++)
	{
		fr[i]=-1;
	}
	for(j=0;j&lt;20;j++)
	{
		flag1=0,flag2=0;
		for(i=0;i&lt;3;i++)
		{
			if(fr[i]==p[j])
			{
				flag1=1;
				flag2=1;
				break;
			}
		}
		if(flag1==0)
		{
			for(i=0;i&lt;3;i++)
			{
				if(fr[i]==-1)
				{
					fr[i]=p[j];
					flag2=1;
					break;
				}
			}
		}
		if(flag2==0)
		{
			for(i=0;i&lt;3;i++)
				fs[i]=0;
			for(k=j-1,l=1;l&lt;=frsize-1;l++,k--)
			{
				for(i=0;i&lt;3;i++)
				{
					if(fr[i]==p[k])
						fs[i]=1;
				}
			}
			for(i=0;i&lt;3;i++)
			{
				if(fs[i]==0)
					index=i;
			}
			fr[index]=p[j];
			pf++;
		}
		display();
	}
	printf("\n no of page faults :%d",pf);
	getch();
}
void display()
{
	int i;
	printf("\n");
	for(i=0;i&lt;3;i++)
		printf("\t%d",fr[i]);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-advanced/least-recently-used-paging-algorithm/">Least Recently Used Paging Algorithm</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/c-advanced/least-recently-used-paging-algorithm/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>First In First Out Page Replacement Algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/simple/first-in-first-out-page-replacement-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/simple/first-in-first-out-page-replacement-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Arun]]></dc:creator>
		<pubDate>Wed, 17 Apr 2013 09:25:03 +0000</pubDate>
				<category><![CDATA[Simple programs]]></category>
		<category><![CDATA[FIFO]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=4035</guid>

					<description><![CDATA[<p>C program for First In First Out Page Replacement Algorithm #include "stdio.h" int fr[3]; void main() { void display(); int i,j,page[12]={2,3,2,1,5,2,4,5,3,2,5,2}; int flag1=0,flag2=0,pf=0,frsize=3,top=0; for(i=0;i</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/simple/first-in-first-out-page-replacement-algorithm/">First In First Out Page Replacement Algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C program for First In First Out Page Replacement Algorithm</p>
<pre lang="C" line="1">
#include "stdio.h"
int fr[3];

void main()
{
	void display();
	int i,j,page[12]={2,3,2,1,5,2,4,5,3,2,5,2};
	int flag1=0,flag2=0,pf=0,frsize=3,top=0;
	for(i=0;i<3;i++)
	{
		fr[i]=-1;
	}
	for(j=0;j<12;j++)
	{
		flag1=0;
		flag2=0;
		for(i=0;i<12;i++)
		{
			if(fr[i]==page[j])
			{
				flag1=1;
				flag2=1;
				break;
			}
		}
		if(flag1==0)
		{
			for(i=0;i=frsize)
				top=0;
		}
		display();
	}
	printf("Number of page faults : %d ",pf);
	getch();
}
void display()
{
	int i;
	printf("\n");
	for(i=0;i<3;i++)
		printf("%d\t",fr[i]);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/simple/first-in-first-out-page-replacement-algorithm/">First In First Out Page Replacement Algorithm</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/simple/first-in-first-out-page-replacement-algorithm/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<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[Stacks using array]]></category>
		<category><![CDATA[c program]]></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>
		<item>
		<title>C Program for Simple DSC order Priority QUEUE Implementation using Structure</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation-using-structure-2/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation-using-structure-2/#respond</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 17:07:15 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Priority QUEUE]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[C Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3335</guid>

					<description><![CDATA[<p>C Program for Simple DSC order Priority QUEUE Implementation using Structure. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #define SIZE 5 /* Size of Queue */ int f=0,r=-1; /* Global declarations */ typedef struct PRQ { int ele; int pr; }PriorityQ; PriorityQ PQ[SIZE]; PQinsert(int elem, int pre) { int i;</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation-using-structure-2/">C Program for Simple DSC order Priority QUEUE Implementation using Structure</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program for Simple DSC order Priority QUEUE Implementation using Structure.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#define SIZE 5            /* Size of Queue */
int f=0,r=-1;       /* Global declarations */
typedef struct PRQ
{
    int ele;
    int pr;
}PriorityQ;

PriorityQ PQ[SIZE];

PQinsert(int elem, int pre)
{
    int i;       /* Function for Insert operation */
    if( Qfull()) printf("\n\n Overflow!!!!\n\n");
    else
    {
        i=r;
        ++r;
        while(PQ[i].pr <= pre &#038;&#038; i >= 0) /* Find location for new elem */
        {
            PQ[i+1]=PQ[i];
            i--;
        }
        PQ[i+1].ele=elem;
        PQ[i+1].pr=pre;
    }
}

PriorityQ PQdelete()
{                      /* Function for Delete operation */
    PriorityQ p;
    if(Qempty()){ printf("\n\nUnderflow!!!!\n\n");
    p.ele=-1;p.pr=-1;
    return(p); }
    else
    {
        p=PQ[f];
        f=f+1;
        return(p);
    }
}
int Qfull()
{                     /* Function to Check Queue Full */
    if(r==SIZE-1) return 1;
    return 0;
}

int Qempty()
{                    /* Function to Check Queue Empty */
    if(f > r) return 1;
    return 0;
}

display()
{                  /* Function to display status of Queue */
    int i;
    if(Qempty()) printf(" \n Empty Queue\n");
    else
    {
        printf("Front->");
        for(i=f;i<=r;i++)
            printf("[%d,%d] ",PQ[i].ele,PQ[i].pr);
        printf("<-Rear");
    }
}

main()
{                         /* Main Program */
    int opn;
    PriorityQ p;
    do
    {
        clrscr();
        printf("\n ### Priority Queue Operations(DSC order) ### \n\n");
        printf("\n Press 1-Insert, 2-Delete,3-Display,4-Exit\n");
        printf("\n Your option ? ");
        scanf("%d",&#038;opn);
        switch(opn)
        {
        case 1: printf("\n\nRead the element and its Priority?");
            scanf("%d%d",&#038;p.ele,&#038;p.pr);
            PQinsert(p.ele,p.pr); break;
        case 2: p=PQdelete();
            if( p.ele != -1)
                printf("\n\nDeleted Element is %d \n",p.ele);
            break;
        case 3: printf("\n\nStatus of Queue\n\n");
            display(); 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-simple-dsc-order-priority-queue-implementation-using-structure-2/">C Program for Simple DSC order Priority QUEUE Implementation using Structure</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-simple-dsc-order-priority-queue-implementation-using-structure-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C Program for Simple DSC order Priority QUEUE Implementation using Structure</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation-using-structure/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation-using-structure/#respond</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 17:06:15 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[C Structure]]></category>
		<category><![CDATA[Priority QUEUE]]></category>
		<category><![CDATA[c program]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3333</guid>

					<description><![CDATA[<p>C Program for Simple DSC order Priority QUEUE Implementation using Structure. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT. #define SIZE 5 /* Size of Queue */ int f=0,r=-1; /* Global declarations */ typedef struct PRQ { int ele; int pr; }PriorityQ; PriorityQ PQ[SIZE]; PQinsert(int elem, int pre) { int i;</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation-using-structure/">C Program for Simple DSC order Priority QUEUE Implementation using Structure</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program for Simple DSC order Priority QUEUE Implementation using Structure.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT.</p>
<pre lang="C" line="1">
#define SIZE 5            /* Size of Queue */
int f=0,r=-1;       /* Global declarations */
typedef struct PRQ
{
    int ele;
    int pr;
}PriorityQ;

PriorityQ PQ[SIZE];

PQinsert(int elem, int pre)
{
    int i;       /* Function for Insert operation */
    if( Qfull()) printf("\n\n Overflow!!!!\n\n");
    else
    {
        i=r;
        ++r;
        while(PQ[i].pr <= pre &#038;&#038; i >= 0) /* Find location for new elem */
        {
            PQ[i+1]=PQ[i];
            i--;
        }
        PQ[i+1].ele=elem;
        PQ[i+1].pr=pre;
    }
}

PriorityQ PQdelete()
{                      /* Function for Delete operation */
    PriorityQ p;
    if(Qempty()){ printf("\n\nUnderflow!!!!\n\n");
    p.ele=-1;p.pr=-1;
    return(p); }
    else
    {
        p=PQ[f];
        f=f+1;
        return(p);
    }
}

int Qfull()
{                     /* Function to Check Queue Full */
    if(r==SIZE-1) return 1;
    return 0;
}

int Qempty()
{                    /* Function to Check Queue Empty */
    if(f > r) return 1;
    return 0;
}

display()
{                  /* Function to display status of Queue */
    int i;
    if(Qempty()) printf(" \n Empty Queue\n");
    else
    {
        printf("Front->");
        for(i=f;i<=r;i++)
            printf("[%d,%d] ",PQ[i].ele,PQ[i].pr);
        printf("<-Rear");
    }
}

main()
{                         /* Main Program */
    int opn;
    PriorityQ p;
    do
    {
        clrscr();
        printf("\n ### Priority Queue Operations(DSC order) ### \n\n");
        printf("\n Press 1-Insert, 2-Delete,3-Display,4-Exit\n");
        printf("\n Your option ? ");
        scanf("%d",&#038;opn);
        switch(opn)
        {
        case 1: printf("\n\nRead the element and its Priority?");
            scanf("%d%d",&#038;p.ele,&#038;p.pr);
            PQinsert(p.ele,p.pr); break;
        case 2: p=PQdelete();
            if( p.ele != -1)
                printf("\n\nDeleted Element is %d \n",p.ele);
            break;
        case 3: printf("\n\nStatus of Queue\n\n");
            display(); 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-simple-dsc-order-priority-queue-implementation-using-structure/">C Program for Simple DSC order Priority QUEUE Implementation using Structure</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-simple-dsc-order-priority-queue-implementation-using-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C Program for Simple ASC order Priority QUEUE Implementation using Structure</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-asc-order-priority-queue-implementation-using-structure/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-asc-order-priority-queue-implementation-using-structure/#respond</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 17:04:28 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[C Structure]]></category>
		<category><![CDATA[c Queue]]></category>
		<category><![CDATA[c program]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3331</guid>

					<description><![CDATA[<p>C Program for Simple ASC order Priority QUEUE Implementation using Structure. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #define SIZE 5 /* Size of Queue */ int f=0,r=-1; /* Global declarations */ typedef struct PRQ { int ele; int pr; }PriorityQ; PriorityQ PQ[SIZE]; PQinsert(int elem, int pre) { int i;</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-asc-order-priority-queue-implementation-using-structure/">C Program for Simple ASC order Priority QUEUE Implementation using Structure</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program for Simple ASC order Priority QUEUE Implementation using Structure.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#define SIZE 5            /* Size of Queue */
int f=0,r=-1;       /* Global declarations */
typedef struct PRQ
{
    int ele;
    int pr;
}PriorityQ;

PriorityQ PQ[SIZE];

PQinsert(int elem, int pre)
{
    int i;       /* Function for Insert operation */
    if( Qfull()) printf("\n\n Overflow!!!!\n\n");
    else
    {
        i=r;
        ++r;
        while(PQ[i].pr >= pre && i >= 0) /* Find location for new elem */
        {
            PQ[i+1]=PQ[i];
            i--;
        }
        PQ[i+1].ele=elem;
        PQ[i+1].pr=pre;
    }
}

PriorityQ PQdelete()
{                      /* Function for Delete operation */
    PriorityQ p;
    if(Qempty()){ printf("\n\nUnderflow!!!!\n\n");
    p.ele=-1;p.pr=-1;
    return(p); }
    else
    {
        p=PQ[f];
        f=f+1;
        return(p);
    }
}
int Qfull()
{                     /* Function to Check Queue Full */
    if(r==SIZE-1) return 1;
    return 0;
}

int Qempty()
{                    /* Function to Check Queue Empty */
    if(f > r) return 1;
    return 0;
}

display()
{                  /* Function to display status of Queue */
    int i;
    if(Qempty()) printf(" \n Empty Queue\n");
    else
    {
        printf("Front->");
        for(i=f;i<=r;i++)
            printf("[%d,%d] ",PQ[i].ele,PQ[i].pr);
        printf("<-Rear");
    }
}

main()
{                         /* Main Program */
    int opn;
    PriorityQ p;
    do
    {
        clrscr();
        printf("\n ### Priority Queue Operations(DSC order) ### \n\n");
        printf("\n Press 1-Insert, 2-Delete,3-Display,4-Exit\n");
        printf("\n Your option ? ");
        scanf("%d",&#038;opn);
        switch(opn)
        {
        case 1: printf("\n\nRead the element and its Priority?");
            scanf("%d%d",&#038;p.ele,&#038;p.pr);
            PQinsert(p.ele,p.pr); break;
        case 2: p=PQdelete();
            if( p.ele != -1)
                printf("\n\nDeleted Element is %d \n",p.ele);
            break;
        case 3: printf("\n\nStatus of Queue\n\n");
            display(); 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-simple-asc-order-priority-queue-implementation-using-structure/">C Program for Simple ASC order Priority QUEUE Implementation using Structure</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-simple-asc-order-priority-queue-implementation-using-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C Program for Simple DSC order Priority QUEUE Implementation</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation/#respond</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 17:03:07 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[DSC order Priority QUEUE]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[QUEUE Implementation]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3329</guid>

					<description><![CDATA[<p>C Program for Simple DSC order Priority QUEUE Implementation. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #define SIZE 5 /* Size of Queue */ int PQ[SIZE],f=0,r=-1; /* Global declarations */ PQinsert(int elem) { int i; /* Function for Insert operation */ if( Qfull()) printf("\n\n Overflow!!!!\n\n"); else { i=r; ++r; while(PQ[i]</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-dsc-order-priority-queue-implementation/">C Program for Simple DSC order Priority QUEUE Implementation</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program for Simple DSC order Priority QUEUE Implementation.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#define SIZE 5            /* Size of Queue */
int PQ[SIZE],f=0,r=-1;       /* Global declarations */

PQinsert(int elem)
{
    int i;       /* Function for Insert operation */
    if( Qfull()) printf("\n\n Overflow!!!!\n\n");
    else
    {
        i=r;
        ++r;
        while(PQ[i] <= elem &#038;&#038; i >= 0) /* Find location for new elem */
        {
            PQ[i+1]=PQ[i];
            i--;
        }
        PQ[i+1]=elem;
    }
}

int PQdelete()
{                      /* Function for Delete operation */
    int elem;
    if(Qempty()){ printf("\n\nUnderflow!!!!\n\n");
    return(-1); }
    else
    {
        elem=PQ[f];
        f=f+1;
        return(elem);
    }
}

int Qfull()
{                     /* Function to Check Queue Full */
    if(r==SIZE-1) return 1;
    return 0;
}

int Qempty()
{                    /* Function to Check Queue Empty */
    if(f > r) return 1;
    return 0;
}

display()
{                  /* Function to display status of Queue */
    int i;
    if(Qempty()) printf(" \n Empty Queue\n");
    else
    {
        printf("Front->");
        for(i=f;i<=r;i++)
            printf("%d ",PQ[i]);
        printf("<-Rear");
    }
}

main()
{                         /* Main Program */
    int opn,elem;
    do
    {
        clrscr();
        printf("\n ### Priority Queue Operations(DSC order) ### \n\n");
        printf("\n Press 1-Insert, 2-Delete,3-Display,4-Exit\n");
        printf("\n Your option ? ");
        scanf("%d",&#038;opn);
        switch(opn)
        {
        case 1: printf("\n\nRead the element to be Inserted ?");
            scanf("%d",&#038;elem);
            PQinsert(elem); break;
        case 2: elem=PQdelete();
            if( elem != -1)
                printf("\n\nDeleted Element is %d \n",elem);
            break;
        case 3: printf("\n\nStatus of Queue\n\n");
            display(); 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-simple-dsc-order-priority-queue-implementation/">C Program for Simple DSC order Priority QUEUE Implementation</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-simple-dsc-order-priority-queue-implementation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C Program for Simple ASC order Priority QUEUE Implementation</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-asc-order-priority-queue-implementation/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-asc-order-priority-queue-implementation/#comments</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 17:01:54 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[Priority QUEUE]]></category>
		<category><![CDATA[QUEUE Implementation]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3327</guid>

					<description><![CDATA[<p>C Program for Simple ASC order Priority QUEUE Implementation. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #define SIZE 5 /* Size of Queue */ int PQ[SIZE],f=0,r=-1; /* Global declarations */ PQinsert(int elem) { int i; /* Function for Insert operation */ if( Qfull()) printf("\n\n Overflow!!!!\n\n"); else { i=r; ++r; while(PQ[i]</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-simple-asc-order-priority-queue-implementation/">C Program for Simple ASC order Priority QUEUE Implementation</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program for Simple ASC order Priority QUEUE Implementation.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#define SIZE 5            /* Size of Queue */
int PQ[SIZE],f=0,r=-1;       /* Global declarations */

PQinsert(int elem)
{
    int i;       /* Function for Insert operation */
    if( Qfull()) printf("\n\n Overflow!!!!\n\n");
    else
    {
        i=r;
        ++r;
        while(PQ[i] >= elem && i >= 0) /* Find location for new elem */
        {
            PQ[i+1]=PQ[i];
            i--;
        }
        PQ[i+1]=elem;
    }
}

int PQdelete()
{                      /* Function for Delete operation */
    int elem;
    if(Qempty()){ printf("\n\nUnderflow!!!!\n\n");
    return(-1); }
    else
    {
        elem=PQ[f];
        f=f+1;
        return(elem);
    }
}

int Qfull()
{                     /* Function to Check Queue Full */
    if(r==SIZE-1) return 1;
    return 0;
}

int Qempty()
{                    /* Function to Check Queue Empty */
    if(f > r) return 1;
    return 0;
}

display()
{                  /* Function to display status of Queue */
    int i;
    if(Qempty()) printf(" \n Empty Queue\n");
    else
    {
        printf("Front->");
        for(i=f;i<=r;i++)
            printf("%d ",PQ[i]);
        printf("<-Rear");
    }
}

main()
{                         /* Main Program */
    int opn,elem;
    do
    {
        clrscr();
        printf("\n ### Priority Queue Operations(ASC order) ### \n\n");
        printf("\n Press 1-Insert, 2-Delete,3-Display,4-Exit\n");
        printf("\n Your option ? ");
        scanf("%d",&#038;opn);
        switch(opn)
        {
        case 1: printf("\n\nRead the element to be Inserted ?");
            scanf("%d",&#038;elem);
            PQinsert(elem); break;
        case 2: elem=PQdelete();
            if( elem != -1)
                printf("\n\nDeleted Element is %d \n",elem);
            break;
        case 3: printf("\n\nStatus of Queue\n\n");
            display(); 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-simple-asc-order-priority-queue-implementation/">C Program for Simple ASC order Priority QUEUE Implementation</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-simple-asc-order-priority-queue-implementation/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to convert Prefix Expression into Postfix</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-to-convert-prefix-expression-into-postfix/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-to-convert-prefix-expression-into-postfix/#comments</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 17:00:21 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Prefix to Postfix]]></category>
		<category><![CDATA[c program]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3325</guid>

					<description><![CDATA[<p>C Program to convert Prefix Expression into Postfix . Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #include #include char opnds[50][80],oprs[50]; int topr=-1,topd=-1; pushd(char *opnd) { strcpy(opnds[++topd],opnd); } char *popd() { return(opnds[topd--]); } pushr(char opr) { oprs[++topr]=opr; } char popr() { return(oprs[topr--]); } int empty(int t) { if( t == 0)</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-to-convert-prefix-expression-into-postfix/">C Program to convert Prefix Expression into Postfix</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program to convert Prefix Expression into Postfix .<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#include <string.h>
#include <ctype.h>
char opnds[50][80],oprs[50];
int  topr=-1,topd=-1;
pushd(char *opnd)
{
    strcpy(opnds[++topd],opnd);
}
char *popd()
{
    return(opnds[topd--]);
}

pushr(char opr)
{
    oprs[++topr]=opr;
}
char popr()
{
    return(oprs[topr--]);
}
int empty(int t)
{
    if( t == 0) return(1);
    return(0);
}

main()
{
    char prfx[50],ch,str[50],opnd1[50],opnd2[50],opr[2];
    int i=0,k=0,opndcnt=0;
    gets(prfx);
    printf(" Given Prefix Expression : %s\n",prfx);
    while( (ch=prfx[i++]) != '\0')
    {
        if(isalnum(ch))
        {
            str[0]=ch; str[1]='\0';
            pushd(str); opndcnt++;
            if(opndcnt >= 2)
            {
                strcpy(opnd2,popd());
                strcpy(opnd1,popd());
                strcpy(str,opnd1);
                strcat(str,opnd2);
                ch=popr();
                opr[0]=ch;opr[1]='\0';
                strcat(str,opr);
                pushd(str);
                opndcnt-=1;
            }
        }
        else
        {
            pushr(ch);
            if(opndcnt==1)opndcnt=0;  /* operator followed by single operand*/
        }
    }
    if(!empty(topd))
    {
        strcpy(opnd2,popd());
        strcpy(opnd1,popd());
        strcpy(str,opnd1);
        strcat(str,opnd2);
        ch=popr();
        opr[0]=ch;opr[1]='\0';
        strcat(str,opr);
        pushd(str);
    }
    printf(" Postfix Expression: ");
    puts(opnds[topd]);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-to-convert-prefix-expression-into-postfix/">C Program to convert Prefix Expression into Postfix</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-to-convert-prefix-expression-into-postfix/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>C Program to convert Prefix Expression into INFIX</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-to-convert-prefix-expression-into-infix/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-to-convert-prefix-expression-into-infix/#comments</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 16:58:41 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[Prefix into INFIX]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3323</guid>

					<description><![CDATA[<p>C Program to convert Prefix Expression into INFIX. Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #include #include char opnds[50][80],oprs[50]; int topr=-1,topd=-1; pushd(char *opnd) { strcpy(opnds[++topd],opnd); } char *popd() { return(opnds[topd--]); } pushr(char opr) { oprs[++topr]=opr; } char popr() { return(oprs[topr--]); } int empty(int t) { if( t == 0) return(1);</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-to-convert-prefix-expression-into-infix/">C Program to convert Prefix Expression into INFIX</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program to convert Prefix Expression into INFIX.<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#include <string.h>
#include <ctype.h>
char opnds[50][80],oprs[50];
int  topr=-1,topd=-1;
pushd(char *opnd)
{
    strcpy(opnds[++topd],opnd);
}
char *popd()
{
    return(opnds[topd--]);
}

pushr(char opr)
{
    oprs[++topr]=opr;
}
char popr()
{
    return(oprs[topr--]);
}
int empty(int t)
{
    if( t == 0) return(1);
    return(0);
}

main()
{
    char prfx[50],ch,str[50],opnd1[50],opnd2[50],opr[2];
    int i=0,k=0,opndcnt=0;
    gets(prfx);
    printf(" Given Prefix Expression : %s\n",prfx);
    while( (ch=prfx[i++]) != '\0')
    {
        if(isalnum(ch))
        {
            str[0]=ch; str[1]='\0';
            pushd(str); opndcnt++;
            if(opndcnt >= 2)
            {
                strcpy(opnd2,popd());
                strcpy(opnd1,popd());
                strcpy(str,"(");
                strcat(str,opnd1);
                ch=popr();
                opr[0]=ch;opr[1]='\0';
                strcat(str,opr);
                strcat(str,opnd2);
                strcat(str,")");
                pushd(str);
                opndcnt-=1;
            }
        }
        else
        {
            pushr(ch);
            if(opndcnt==1)opndcnt=0;  /* operator followed by single operand*/
        }
    }
    if(!empty(topd))
    {
        strcpy(opnd2,popd());
        strcpy(opnd1,popd());
        strcpy(str,"(");
        strcat(str,opnd1);
        ch=popr();
        opr[0]=ch;opr[1]='\0';
        strcat(str,opr);
        strcat(str,opnd2);
        strcat(str,")");
        pushd(str);
    }
    printf(" Infix Expression: ");
    puts(opnds[topd]);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-advanced/c-program-to-convert-prefix-expression-into-infix/">C Program to convert Prefix Expression into INFIX</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/c-advanced/c-program-to-convert-prefix-expression-into-infix/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
