/*Linked List Implementation of STACK*/
/*Checking of parenthesis in expressions*/
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define M 100
typedef struct node *nd;
struct node
{
char p;
nd next;
}NODE;
void getExpression(char expr[]);
void checkParenthesis(char expr[],int *);
void dispResult(int);
nd top,bottom;
int main(void)
{
char expr[M];
int r;
getExpression(expr);
checkParenthesis(expr,&r);
dispResult(r);
return 0;
}
void getExpression(char expr[])
{
clrscr();
printf("Input an expression: ");
gets(expr);
}
void checkParenthesis(char expr[],int *r)
{
int f=0,l,i;
char e;
nd tp,t;
top = NULL;
bottom = NULL;
l = strlen(expr);
for(i=0;i<l;i++)
{
e=expr[i];
if(e == '(')
{
tp = malloc(sizeof(NODE));
tp->p=e;
if((top==NULL) && (bottom==NULL))
{
tp->next = NULL;
top = tp;
bottom = tp;
}
else
{
tp->next=top;
top=tp;
tp=NULL;
}
}
else if(e==')')
{
if(top==bottom)
{
if(top==NULL)
{
f=1;
break;
}
else
{
top=NULL;
bottom=NULL;
}}
else
{
t=top;
top=top->next;
t->next=NULL;
}
}
}/*end of for loop*/
if(top != NULL)
f=1;
*r=f;
}/*end of function checkParenthesis*/
void dispResult(int r)
{
clrscr();
if(r==0)
printf("The expression has a balance parentheses.");
else if(r>0)
printf("Unbalanced parentheses.");
getch();
}
/*
if(top==bottom)
{
top=NULL;
bottom=NULL;
}
else
{
if((top==NULL)&&(bottom==NULL))
{
f=1;
break;
}
else
{
t =top;
top = top->next;
t->next = NULL;
}
}
}
*/
/*eahjie*/
Yes, you can use for-loop in a C program compiled by Turbo C.
Editor - edits text Compiler - compiles the program Linker - links the program Debugger - helps finding bugs
In Turbo Pascal, you can create a stack by defining a dynamic array or a record that holds the stack elements along with a pointer or an index to track the top of the stack. You would typically create procedures for basic stack operations like Push to add an element, Pop to remove the top element, and IsEmpty to check if the stack is empty. Here's a simple example: const MaxSize = 100; type Stack = record items: array[1..MaxSize] of Integer; top: Integer; end; procedure Initialize(var s: Stack); begin s.top := 0; end; procedure Push(var s: Stack; value: Integer); begin if s.top < MaxSize then begin s.top := s.top + 1; s.items[s.top] := value; end; end; function Pop(var s: Stack): Integer; begin if s.top > 0 then begin Pop := s.items[s.top]; s.top := s.top - 1; end; end; function IsEmpty(s: Stack): Boolean; begin IsEmpty := s.top = 0; end; This code initializes a stack, allows pushing and popping of elements, and includes a function to check if the stack is empty.
Turbo c program is from Borland which is an integrated development environment and a computer language. Some of the parts of turbo c were incorporated from the wizard c in 1987, but it was first developed by Dennis Ritchie in 1970.
Turbo Pascal is a style of computer programming. This type of writing language can be used to create a program that prints the alphabet backwards.
Yes, you can use for-loop in a C program compiled by Turbo C.
tagprice
Turbo c3 or Turbo c4. R.P. Hammad Khan_Haider...
1. Turbo C is an example of Integrated Developing Environment. 2. Turbo C has example programs, the most important is bgidemo.c
Editor - edits text Compiler - compiles the program Linker - links the program Debugger - helps finding bugs
With program DosBox,
File/Open
Turbo c program is from Borland which is an integrated development environment and a computer language. Some of the parts of turbo c were incorporated from the wizard c in 1987, but it was first developed by Dennis Ritchie in 1970.
They are example programs written in Turbo Pascal.
Eric P. Bloom has written: 'The Turbo C++ trilogy' -- subject(s): C (Computer program language), C++ (Computer program language), Turbo C (Computer file), Turbo C++ 'Turbo C Plus Plus Trilogy' 'The C trilogy' -- subject(s): C (Computer program language)
Turbo Pascal is a style of computer programming. This type of writing language can be used to create a program that prints the alphabet backwards.
BGIDEMO.C is an example.