- SAMD21J18A microcontroller
- One mechanical reset button
- One mechanical user pushbutton (wake-up, bootloader entry or general purpose)
- One yellow user LED
- 32.768kHz crystal
- USB interface, device and reduced host mode
- 8 Mbit Serial Flash
- 3 Xplained Pro extension headers
- Embedded Debugger
- Auto-ID for board identification in Atmel Studio 6.1
- One yellow status LED
- One green board power LED
- Symbolic debug of complex data types including scope information
- Programming and debugging
- Data Gateway Interface: SPI, I²C, 4 GPIOs
- Virtual COM port (CDC)
- USB powered
- Supported with application examples in Atmel Software Framework
Search
Tuesday, November 3, 2015
SAMD21 Features
Samd21 Firmware Upgrade(Edbg)
Operation mode Power LED Status LED
Normal operation Power LED is lit when power is applied to the board. Activity indicator, LED flashes every time something happens on the EDBG.
Bootloader mode (idle) The power LED and the status LED blinks simultaneously.
Bootloader mode (firmware upgrade) The power LED and the status LED blinks in an alternating pattern.
1-> C:\Users\xxxxx\Documents>atfw -h
Usage: atfw [options] [arguments]
Options:
-a, --archive .zip
Archive containing firmware upgrade image.
-h, --help Display help information.
-l, --list List connected tools.
-i, --id Print boot loader id (edbg only).
-t, --tool Tool name: edbg, medbg, avrone, jtagicemkii, jtagice3
stk600, qt600, avrispmkii or avrdragon.
-s, --serialnumber The programmer/debugger serial number.
-q, --quiet Do not display activity indicator.
-V, --version Display version number.
-r, --read Read firmware version on tool.
-n --nographics No progress bar, but result alone will be displayed
Example:
atfw -a myImage.zip -t jtagice3 -s 123456789ABC
2-> C:\Users\xxxxx\Documents>atfw -t edbg -a "C:\Program Files (x86)\Atmel\Atmel Studio 6.2\tools\EDBG\edbg_fw.zip"
Found edbg:ATML2130021800001691
Waiting for bootloader usb enumeration: [==========]
Upgrading MCU: [==========]
Successful upgrade
Doubly Linked List
#include<stdio.h>
typedef struct node
{
int data;
struct node *next;
struct node *prev;
}NODE;
NODE *start=NULL,*top,*temp;
void *Create_Node(int value);
void Insert_At_Last();
void Display_Start_To_End();
void Display_End_To_Start();
void Insert_At_Position();
void Delete_At_Last();
void Delete_At_Position();
void Search();
void Update_Value();
void Node_Count();
void main()
{
int choice;
while(1)
{
printf("\n ENTER CHOISE \n 1.INSERT AT LAST \n 2.Delete_At_Last \n 3.Insert_At_Position \n 4.Display_Start_To_End \n 5.Display_End_To_Start \n 6.Delete_At_Position \n 7.Search \n 8.Update_Value \n 9.Node Count \n 10.Exit \n");
printf("\nEnter Your Choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
Insert_At_Last();
break;
case 2:
Delete_At_Last();
break;
case 3:
Insert_At_Position();
break;
case 4:
Delete_At_Position();
break;
case 5:
Display_Start_To_End();
break;
case 6:
Display_End_To_Start();
break;
case 7:
Search();
break;
case 8:
Update_Value();
break;
case 9:
Node_Count();
break;
case 10:
exit(0);
default:
printf("\nWrong Choice\n");
}
}
}
void *Create_Node(int value)
{
NODE *new_node;
new_node=(NODE *)malloc(sizeof(NODE));
new_node->data=value;
new_node->next=NULL;
new_node->prev=NULL;
return new_node;
}
void Insert_At_Last()
{
int ch;
NODE *new_node;
printf("Enter The Data:-> ");
scanf("%d",&ch);
new_node=Create_Node(ch);
if(start==NULL)
{
start=new_node;
top=new_node;
}
else
{
top->next=new_node;
new_node->prev=top;
top=new_node;
}
}
void Display_Start_To_End()
{
NODE *temp;
printf("Displaying List From Start to End:->\n");
temp=start;
while(temp!=NULL)
{
printf("%d \n",temp->data);
temp=temp->next;
}
}
void Display_End_To_Start()
{
NODE *temp;
printf("Displaying List From End to Start:->\n");
temp=top;
while(temp!=NULL)
{
printf("%d \n",temp->data);
temp=temp->prev;
}
}
void Insert_At_Position()
{
NODE *new_node;
int ch,pos,cnt=1;
printf("\nEnter the Data:->");
scanf("%d",&ch);
new_node=Create_Node(ch);
printf("\nEnter the position:->");
scanf("%d",&pos);
temp=start;
if(pos==1)
{
new_node->next=start;
start->prev=new_node;
start=new_node;
}
else
{
temp=start;
while(cnt<(pos-1))
{
temp=temp->next;
}
new_node->next=temp->next;
temp->next->prev=new_node;
new_node->prev=temp;
temp->next=new_node;
}
}
void Delete_At_Last()
{
top=top->prev;
top->next=NULL;
}
void Delete_At_Position()
{
int pos,cnt=1;
NODE *temp;
printf("\nEnter the Position:->");
scanf("%d",&pos);
temp=start;
while(pos<=(cnt-1))
{
temp=temp->next;
}
temp->next=temp->next->next;
temp->next->prev=temp;
}
void Search()
{
NODE *temp;
int ch,cnt=1;
printf("\nEnter the data to search:->");
scanf("%d",&ch);
temp=start;
while(temp->next!=NULL)
{
if(temp->data==ch)
{
printf("\nData is at position:->%d \n",cnt);
}
temp=temp->next;
cnt++;
}
}
void Update_Value()
{
NODE *ptr;
int Old_val, New_val, flag = 0;
printf("\n...Updating Node Value...\n");
if (start == NULL)
{
printf("\nNo nodes in the list to update\n");
}
else
{
printf("\nEnter the value to be updated:->");
scanf("%d", &Old_val);
printf("\nEnter the newvalue:->");
scanf("%d", &New_val);
for (ptr = start;ptr != NULL;ptr = ptr->next)
{
if (ptr->data == Old_val)
{
ptr->data = New_val;
flag = 1;
break;
}
}
if (flag == 1)
{
printf("\nUpdated Successfully");
}
else
{
printf("\nValue not found in List");
}
}
}
void Node_Count()
{
int cnt;
temp=start;
while(temp!=NULL)
{
temp=temp->next;
cnt++;
}
printf("\nNO.of Nodes In the list is =%d",cnt);
}
typedef struct node
{
int data;
struct node *next;
struct node *prev;
}NODE;
NODE *start=NULL,*top,*temp;
void *Create_Node(int value);
void Insert_At_Last();
void Display_Start_To_End();
void Display_End_To_Start();
void Insert_At_Position();
void Delete_At_Last();
void Delete_At_Position();
void Search();
void Update_Value();
void Node_Count();
void main()
{
int choice;
while(1)
{
printf("\n ENTER CHOISE \n 1.INSERT AT LAST \n 2.Delete_At_Last \n 3.Insert_At_Position \n 4.Display_Start_To_End \n 5.Display_End_To_Start \n 6.Delete_At_Position \n 7.Search \n 8.Update_Value \n 9.Node Count \n 10.Exit \n");
printf("\nEnter Your Choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
Insert_At_Last();
break;
case 2:
Delete_At_Last();
break;
case 3:
Insert_At_Position();
break;
case 4:
Delete_At_Position();
break;
case 5:
Display_Start_To_End();
break;
case 6:
Display_End_To_Start();
break;
case 7:
Search();
break;
case 8:
Update_Value();
break;
case 9:
Node_Count();
break;
case 10:
exit(0);
default:
printf("\nWrong Choice\n");
}
}
}
void *Create_Node(int value)
{
NODE *new_node;
new_node=(NODE *)malloc(sizeof(NODE));
new_node->data=value;
new_node->next=NULL;
new_node->prev=NULL;
return new_node;
}
void Insert_At_Last()
{
int ch;
NODE *new_node;
printf("Enter The Data:-> ");
scanf("%d",&ch);
new_node=Create_Node(ch);
if(start==NULL)
{
start=new_node;
top=new_node;
}
else
{
top->next=new_node;
new_node->prev=top;
top=new_node;
}
}
void Display_Start_To_End()
{
NODE *temp;
printf("Displaying List From Start to End:->\n");
temp=start;
while(temp!=NULL)
{
printf("%d \n",temp->data);
temp=temp->next;
}
}
void Display_End_To_Start()
{
NODE *temp;
printf("Displaying List From End to Start:->\n");
temp=top;
while(temp!=NULL)
{
printf("%d \n",temp->data);
temp=temp->prev;
}
}
void Insert_At_Position()
{
NODE *new_node;
int ch,pos,cnt=1;
printf("\nEnter the Data:->");
scanf("%d",&ch);
new_node=Create_Node(ch);
printf("\nEnter the position:->");
scanf("%d",&pos);
temp=start;
if(pos==1)
{
new_node->next=start;
start->prev=new_node;
start=new_node;
}
else
{
temp=start;
while(cnt<(pos-1))
{
temp=temp->next;
}
new_node->next=temp->next;
temp->next->prev=new_node;
new_node->prev=temp;
temp->next=new_node;
}
}
void Delete_At_Last()
{
top=top->prev;
top->next=NULL;
}
void Delete_At_Position()
{
int pos,cnt=1;
NODE *temp;
printf("\nEnter the Position:->");
scanf("%d",&pos);
temp=start;
while(pos<=(cnt-1))
{
temp=temp->next;
}
temp->next=temp->next->next;
temp->next->prev=temp;
}
void Search()
{
NODE *temp;
int ch,cnt=1;
printf("\nEnter the data to search:->");
scanf("%d",&ch);
temp=start;
while(temp->next!=NULL)
{
if(temp->data==ch)
{
printf("\nData is at position:->%d \n",cnt);
}
temp=temp->next;
cnt++;
}
}
void Update_Value()
{
NODE *ptr;
int Old_val, New_val, flag = 0;
printf("\n...Updating Node Value...\n");
if (start == NULL)
{
printf("\nNo nodes in the list to update\n");
}
else
{
printf("\nEnter the value to be updated:->");
scanf("%d", &Old_val);
printf("\nEnter the newvalue:->");
scanf("%d", &New_val);
for (ptr = start;ptr != NULL;ptr = ptr->next)
{
if (ptr->data == Old_val)
{
ptr->data = New_val;
flag = 1;
break;
}
}
if (flag == 1)
{
printf("\nUpdated Successfully");
}
else
{
printf("\nValue not found in List");
}
}
}
void Node_Count()
{
int cnt;
temp=start;
while(temp!=NULL)
{
temp=temp->next;
cnt++;
}
printf("\nNO.of Nodes In the list is =%d",cnt);
}
Singly Linked List
#include<stdio.h>
typedef struct node
{
int data;
struct node *next;
}NODE;
NODE *new_node,*temp,*ptr;
NODE *start=NULL,*last=NULL;
void Insert_At_last();
void Insert_At_Position();
NODE *Create_Node(int valu);
void Delete_At_Position();
void Search();
void Display();
void Reverse();
void Update_Value();
void Node_Count();
void main()
{
int choice;
while(1)
{
printf("ENTER CHOISE \n 1.INSERT AT LAST \n 2.INSERT AT POSITION \n 3.DISPLAY \n 4.DELETE AT POSITION \n 5.SEARCH \n 6.REVERSE \n 7.UPDATE VALUE \n 8.NODE COUNT \n 9.EXIT ");
printf("\nEnter Your Choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
Insert_At_Last();
break;
case 2:
Insert_At_Position();
break;
case 3:
Display();
break;
case 4:
Delete_At_Position();
break;
case 5:
Search();
break;
case 6:
Reverse();
break;
case 7:
Update_Value();
break;
case 8:
Node_Count();
break;
case 9:
exit(0);
default:
printf("\nWrong Choice\n");
}
}
}
NODE *Create_Node(int valu)
{
new_node=(NODE *)malloc(sizeof(NODE));
new_node->data=valu;
new_node->next=NULL;
return new_node;
}
void Insert_At_Last()
{
int val;
printf("\nEnter the data:");
scanf("%d",&val);
new_node=Create_Node(val);
if(start==last && last==NULL)
{
start=last=new_node;
}
else
{
last->next=new_node;
last=new_node;
}
}
void Delete_At_Position()
{
int cnt=0,pos,i;
printf("Enter the Position:->");
scanf("%d",&pos);
if(pos==1)
{
if(start==NULL)
{
printf("\n LIST IS EMPTY \n");
}
else
{
start=start->next;
}
}
else
{
temp=start;
while(pos>2)
{
temp=temp->next;
pos--;
}
temp->next=temp->next->next;
}
}
void Insert_At_Position()
{
int cnt=0,pos,val,i;
printf("Enter the value:->");
scanf("%d",&val);
new_node=Create_Node(val);
printf("Enter the Position:->");
scanf("%d",&pos);
if(pos==1)
{
temp=start;
start=new_node;
start->next=temp;
}
else
{
temp=start;
while(pos>2)
{
temp=temp->next;
pos--;
}
new_node->next=temp->next;
temp->next=new_node;
}
}
void Search()
{
int ch,cnt=1,a=0;
temp=start;
printf("Enter the data:->");
scanf("%d",&ch);
while (temp != NULL)
{
if (temp->data == ch)
{
printf("Data at position:->%d\n",cnt);
a++;
}
temp = temp->next;
cnt++;
}
if(a==0)
{
printf("Data not found\n\n");
}
else
return;
}
void Display()
{
NODE *temp;
temp=start;
while(temp!=NULL)
{
printf("\n%d",temp->data);
temp=temp->next;
}
}
void Reverse()
{
int cnt=0,i=0,pos;
temp=start;
while(temp!=NULL)
{
temp=temp->next;
cnt++;
}
for(i=cnt;i>0;i--)
{
pos=0;
temp=start;
while(pos!=i-1)
{
temp=temp->next;
pos++;
}
printf("%d \n",temp->data);
}
//return;
}
void Update_Value()
{
int Old_val, New_val, flag = 0;
printf("\n...Updating Node Value...\n");
if (start == NULL)
{
printf("\nNo nodes in the list to update\n");
}
else
{
printf("\nEnter the value to be updated:->");
scanf("%d", &Old_val);
printf("\nEnter the newvalue:->");
scanf("%d", &New_val);
for (ptr = start;ptr != NULL;ptr = ptr->next)
{
if (ptr->data == Old_val)
{
ptr->data = New_val;
flag = 1;
break;
}
}
if (flag == 1)
{
printf("\nUpdated Successfully");
}
else
{
printf("\nValue not found in List");
}
}
}
void Node_Count()
{
int cnt=0;
temp=start;
while(temp!=NULL)
{
temp=temp->next;
cnt++;
}
printf("\nNo.Of Nodes in the linked list:->%d\n\n",cnt);
}
typedef struct node
{
int data;
struct node *next;
}NODE;
NODE *new_node,*temp,*ptr;
NODE *start=NULL,*last=NULL;
void Insert_At_last();
void Insert_At_Position();
NODE *Create_Node(int valu);
void Delete_At_Position();
void Search();
void Display();
void Reverse();
void Update_Value();
void Node_Count();
void main()
{
int choice;
while(1)
{
printf("ENTER CHOISE \n 1.INSERT AT LAST \n 2.INSERT AT POSITION \n 3.DISPLAY \n 4.DELETE AT POSITION \n 5.SEARCH \n 6.REVERSE \n 7.UPDATE VALUE \n 8.NODE COUNT \n 9.EXIT ");
printf("\nEnter Your Choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
Insert_At_Last();
break;
case 2:
Insert_At_Position();
break;
case 3:
Display();
break;
case 4:
Delete_At_Position();
break;
case 5:
Search();
break;
case 6:
Reverse();
break;
case 7:
Update_Value();
break;
case 8:
Node_Count();
break;
case 9:
exit(0);
default:
printf("\nWrong Choice\n");
}
}
}
NODE *Create_Node(int valu)
{
new_node=(NODE *)malloc(sizeof(NODE));
new_node->data=valu;
new_node->next=NULL;
return new_node;
}
void Insert_At_Last()
{
int val;
printf("\nEnter the data:");
scanf("%d",&val);
new_node=Create_Node(val);
if(start==last && last==NULL)
{
start=last=new_node;
}
else
{
last->next=new_node;
last=new_node;
}
}
void Delete_At_Position()
{
int cnt=0,pos,i;
printf("Enter the Position:->");
scanf("%d",&pos);
if(pos==1)
{
if(start==NULL)
{
printf("\n LIST IS EMPTY \n");
}
else
{
start=start->next;
}
}
else
{
temp=start;
while(pos>2)
{
temp=temp->next;
pos--;
}
temp->next=temp->next->next;
}
}
void Insert_At_Position()
{
int cnt=0,pos,val,i;
printf("Enter the value:->");
scanf("%d",&val);
new_node=Create_Node(val);
printf("Enter the Position:->");
scanf("%d",&pos);
if(pos==1)
{
temp=start;
start=new_node;
start->next=temp;
}
else
{
temp=start;
while(pos>2)
{
temp=temp->next;
pos--;
}
new_node->next=temp->next;
temp->next=new_node;
}
}
void Search()
{
int ch,cnt=1,a=0;
temp=start;
printf("Enter the data:->");
scanf("%d",&ch);
while (temp != NULL)
{
if (temp->data == ch)
{
printf("Data at position:->%d\n",cnt);
a++;
}
temp = temp->next;
cnt++;
}
if(a==0)
{
printf("Data not found\n\n");
}
else
return;
}
void Display()
{
NODE *temp;
temp=start;
while(temp!=NULL)
{
printf("\n%d",temp->data);
temp=temp->next;
}
}
void Reverse()
{
int cnt=0,i=0,pos;
temp=start;
while(temp!=NULL)
{
temp=temp->next;
cnt++;
}
for(i=cnt;i>0;i--)
{
pos=0;
temp=start;
while(pos!=i-1)
{
temp=temp->next;
pos++;
}
printf("%d \n",temp->data);
}
//return;
}
void Update_Value()
{
int Old_val, New_val, flag = 0;
printf("\n...Updating Node Value...\n");
if (start == NULL)
{
printf("\nNo nodes in the list to update\n");
}
else
{
printf("\nEnter the value to be updated:->");
scanf("%d", &Old_val);
printf("\nEnter the newvalue:->");
scanf("%d", &New_val);
for (ptr = start;ptr != NULL;ptr = ptr->next)
{
if (ptr->data == Old_val)
{
ptr->data = New_val;
flag = 1;
break;
}
}
if (flag == 1)
{
printf("\nUpdated Successfully");
}
else
{
printf("\nValue not found in List");
}
}
}
void Node_Count()
{
int cnt=0;
temp=start;
while(temp!=NULL)
{
temp=temp->next;
cnt++;
}
printf("\nNo.Of Nodes in the linked list:->%d\n\n",cnt);
}
Stack Using Linked List
#include<stdio.h>
typedef struct node
{
int data;
struct node *next;
struct node *prev;
}NODE;
NODE *start=NULL,*ptr=NULL,*top=NULL;
NODE *Create_node(int val);
void PUSH();
void POP();
void DISPLAY();
void main()
{
int choice;
while(1)
{
printf("Enter Your Choice\n 1.PUSH \n 2.POP \n 3.DIsplay \nEnter Your Choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
PUSH();
break;
case 2:
POP();
break;
case 3:
DISPLAY();
break;
default:
printf("\nWrong choice\n");
}
}
}
NODE *Create_node(int val)
{
NODE *new_node;
new_node=(NODE *)malloc(sizeof(NODE));
new_node->data=val;
new_node->next=NULL;
new_node->prev=NULL;
return new_node;
}
void PUSH()
{
NODE *new_node;
int val;
printf("Enter the Value:");
scanf("%D",&val);
new_node=Create_node(val);
if(start==NULL)
{
start=new_node;
top=new_node;
}
else
{
new_node->prev=top;
top->next=new_node;
top=new_node;
}
}
void POP()
{
struct Node *temp, *var=top;
if(start==NULL)
{
printf("\nStack Empty");
}
else
{
top = top->prev;
free(top);
top->next=NULL;
}
}
void DISPLAY()
{
NODE *ptr;
ptr=start;
printf("DATA\n");
if(start==NULL)
{
printf("Stack is empty");
}
else
{
while(ptr!=NULL)
{
printf("%d\n",ptr->data);
ptr=ptr->next;
}
}
}
typedef struct node
{
int data;
struct node *next;
struct node *prev;
}NODE;
NODE *start=NULL,*ptr=NULL,*top=NULL;
NODE *Create_node(int val);
void PUSH();
void POP();
void DISPLAY();
void main()
{
int choice;
while(1)
{
printf("Enter Your Choice\n 1.PUSH \n 2.POP \n 3.DIsplay \nEnter Your Choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
PUSH();
break;
case 2:
POP();
break;
case 3:
DISPLAY();
break;
default:
printf("\nWrong choice\n");
}
}
}
NODE *Create_node(int val)
{
NODE *new_node;
new_node=(NODE *)malloc(sizeof(NODE));
new_node->data=val;
new_node->next=NULL;
new_node->prev=NULL;
return new_node;
}
void PUSH()
{
NODE *new_node;
int val;
printf("Enter the Value:");
scanf("%D",&val);
new_node=Create_node(val);
if(start==NULL)
{
start=new_node;
top=new_node;
}
else
{
new_node->prev=top;
top->next=new_node;
top=new_node;
}
}
void POP()
{
struct Node *temp, *var=top;
if(start==NULL)
{
printf("\nStack Empty");
}
else
{
top = top->prev;
free(top);
top->next=NULL;
}
}
void DISPLAY()
{
NODE *ptr;
ptr=start;
printf("DATA\n");
if(start==NULL)
{
printf("Stack is empty");
}
else
{
while(ptr!=NULL)
{
printf("%d\n",ptr->data);
ptr=ptr->next;
}
}
}
Stack Using Array
#include<stdio.h>
#define SIZE 5
int stack[SIZE];
int top;
void PUSH();
void POP();
void DISPLAY();
void STACK_COUNT();
void EXIT();
void main()
{
int CHOICE;
while(1)
{
printf("MAIN MENU \n\n 1.PUSH \n 2.POP \n 3.DISPLAY \n 4.STACK COUNT \n5.EXIT \n\nENTER YOUR CHOICE:");
scanf("%d",&CHOICE);
switch(CHOICE)
{
case 1:
PUSH();
break;
case 2:
POP();
break;
case 3:
DISPLAY();
break;
case 4:
STACK_COUNT();
break;
case 5:
EXIT();
break;
default:
printf("\nWRONG CHOISE");
}
}
}
void PUSH()
{
if(top>=SIZE)
{
printf("STACK IS FULL\n\n");
return;
}
else
{
if(top<=0)
top=0;
printf("\nENTER THE ELEMENT:");
scanf("%d",&stack[top++]);
}
}
void POP()
{
if(top<=0)
printf("\nSTACK IS EMPTY\n\n");
else
{
printf("\nPOPED ELEMENT:%d\n\n",stack[--top]);
}
}
void DISPLAY()
{
int i;
if(top<=0)
printf("\nSTACK IS EMPTY\n");
else
{
for(i=(top-1);i>=0;i--)
{
if(i==(top-1))
printf("----> TOP ELEMENT\n");
printf("%d \n",stack[i]);
}
printf("\n");
}
}
void STACK_COUNT()
{
if(top<=0)
printf("STACK IS EMPTY\n\n");
else
{
printf("STACK IS EMPTY WITH %d ELEMENTS\n\n",(SIZE-(top-1)));
}
}
void EXIT()
{
exit(0);
}
#define SIZE 5
int stack[SIZE];
int top;
void PUSH();
void POP();
void DISPLAY();
void STACK_COUNT();
void EXIT();
void main()
{
int CHOICE;
while(1)
{
printf("MAIN MENU \n\n 1.PUSH \n 2.POP \n 3.DISPLAY \n 4.STACK COUNT \n5.EXIT \n\nENTER YOUR CHOICE:");
scanf("%d",&CHOICE);
switch(CHOICE)
{
case 1:
PUSH();
break;
case 2:
POP();
break;
case 3:
DISPLAY();
break;
case 4:
STACK_COUNT();
break;
case 5:
EXIT();
break;
default:
printf("\nWRONG CHOISE");
}
}
}
void PUSH()
{
if(top>=SIZE)
{
printf("STACK IS FULL\n\n");
return;
}
else
{
if(top<=0)
top=0;
printf("\nENTER THE ELEMENT:");
scanf("%d",&stack[top++]);
}
}
void POP()
{
if(top<=0)
printf("\nSTACK IS EMPTY\n\n");
else
{
printf("\nPOPED ELEMENT:%d\n\n",stack[--top]);
}
}
void DISPLAY()
{
int i;
if(top<=0)
printf("\nSTACK IS EMPTY\n");
else
{
for(i=(top-1);i>=0;i--)
{
if(i==(top-1))
printf("----> TOP ELEMENT\n");
printf("%d \n",stack[i]);
}
printf("\n");
}
}
void STACK_COUNT()
{
if(top<=0)
printf("STACK IS EMPTY\n\n");
else
{
printf("STACK IS EMPTY WITH %d ELEMENTS\n\n",(SIZE-(top-1)));
}
}
void EXIT()
{
exit(0);
}
Subscribe to:
Posts (Atom)