Professional Documents
Culture Documents
Getuya
IT 203 – Programming Paradigms
Assignment No. 1
>include <stdio.h#
>include <graphics.h#
>include <dos.h#
>include<conio.h#
>include<process.h#
define SIZE 6#
;int gd=DETECT,gm,maxx,maxy
)(void main
{
;char c
;int i,temp
;s1.top=-1
;initgraph(&gd,&gm,"f:\\tc\\bgi")
;)(maxx=getmaxx
;)(maxy=getmaxy
;startscreen(maxx,maxy)
;)(start_screen
;shell(maxx,maxy)
:START
;)(c=getch
switch (c)
{
;case '1': gotoxy(3,17)
;printf("What element do you wish to push?")
;scanf("%d",&temp)
;push(&s1,temp)
;break
;case '2': gotoxy(3,17)
;pop(&s1)
;break
;case '3': gotoxy(3,17)
;printf("Enter the element you wish to search?")
;scanf("%d",&temp)
;temp=search(&s1,temp)
;gotoxy(5,19)
if (temp==-1)
;printf("Sorry! No results Found!")
else
;printf("The element is at index %d",temp)
;)(getch
;break
;case '4': gotoxy(3,17)
;printf("Enter the POSTION and ELEMENT you wish to insert?")
;scanf("%d %d",&i,&temp)
;insert(&s1,i,temp)
;break
;case '5': gotoxy(3,17)
;printf("Enter the POSTION and ELEMENT you wish to replace?")
;scanf("%d %d",&i,&temp)
;replace(&s1,i,temp)
;break
;case '6': gotoxy(3,17)
;printf("Enter the POSTION you wish to delete from stack?")
;scanf("%d",&temp)
;del(&s1,temp)
;break
;default : gotoxy(3,17)
;printf("Invalid entry! Try again!")
;break
}
for (i=0;i<=6;i++)
{
;gotoxy(3,17+i)
;printf("\t\t\t\t\t\t\t\t\t")
}
;gotoxy(3,17)
;printf("Do You wish to contine?")
;)(c=getch
if (c=='y')
{
;printf("\t\t\t\t\t") gotoxy(3,17);
;goto START
}
;)(closegraph
;)(close
;)(restorecrtmode
}
void printline(void)
{
;int i
for (i=0;i<40;i++)
;)"¯®"(printf
}
Sample Output
>include <iostream.h#
>include <graphics.h#
>include <dos.h#
>include<conio.h#
>include<process.h#
define SIZE 6#
;int gd=DETECT,gm,maxx,maxy
)(void main
{
;char c
;int i,temp
;s1.top=-1
;initgraph(&gd,&gm,"f:\\tc\\bgi")
;)(maxx=getmaxx
;)(maxy=getmaxy
;startscreen(maxx,maxy)
;)(start_screen
;shell(maxx,maxy)
:START
;)(c=getch
switch (c)
{
;case '1': gotoxy(3,17)
;"?cout<<"What element do you wish to push
;cin<<"%d",&temp
;push(&s1,temp)
;break
;case '2': gotoxy(3,17)
;pop(&s1)
;break
;case '3': gotoxy(3,17)
;"?cout<<"Enter the element you wish to search
;cin<<"%d",&temp
;temp=search(&s1,temp)
;gotoxy(5,19)
if (temp==-1)
;printf("Sorry! No results Found!")
else
;printf("The element is at index %d",temp)
;)(getch
;break
;case '4': gotoxy(3,17)
;"?cout<<"Enter the POSTION and ELEMENT you wish to insert
;cin<<"%d %d",&i,&temp
;insert(&s1,i,temp)
;break
;case '5': gotoxy(3,17)
;"?cout<<"Enter the POSTION and ELEMENT you wish to replace
;cin<<"%d %d",&i,&temp
;replace(&s1,i,temp)
;break
;case '6': gotoxy(3,17)
;"?cout<<"Enter the POSTION you wish to delete from stack
;cin<<"%d",&temp
;del(&s1,temp)
;break
;default : gotoxy(3,17)
;"!cout<<"Invalid entry! Try again
;break
}
for (i=0;i<=6;i++)
{
;gotoxy(3,17+i)
;printf("\t\t\t\t\t\t\t\t\t")
}
;gotoxy(3,17)
;"?cout<<"Do You wish to contine
;)(c=getch
if (c=='y')
{
;printf("\t\t\t\t\t") gotoxy(3,17);
;goto START
}
;)(closegraph
;)(close
;)(restorecrtmode
}
void printline(void)
{
;int i
for (i=0;i<40;i++)
;)"¯®"(printf
}
Sample Output
Java
;*.import java.util
Sample Output