#include<stdio.h>
#define STACKSIZE 20
//stack size is 20
int stack[STACKSIZE]={0};
//top of the stack initially -1 which means empty
int tos=-1;
void push(int ele)
{
if(tos>=STACKSIZE)
{
printf("err: Stack is full\n");
}
else
{
tos++;
stack[tos] = ele;
}
}
int pop()
{
if(tos==-1)
{
printf("err: stack is empty\n");
}
else
{
int temp = stack[tos];
tos--;
printf("poped element from the stack is %d\n",temp);
return temp;
}
}
void display()
{
int i;
for(i=0;i<=tos;i++)
printf(" %d\n",stack[i]);
if(tos== -1)
{
printf("err: stack is empty\n");
return;
}
}
int main()
{
int ch,ele;
printf("enter the choice 1-push 2-pop 3-display 9-exit\n");
scanf("%d",&ch);
while(ch!=9)
{
switch(ch)
{
case 1: printf("Enter the ele to push\n");
scanf("%d",&ele);
push(ele);
break;
case 2: ele = pop();
break;
case 3: display();
break;
case 4:
break;
default:
break;
}
printf("enter the choice 1-push 2-pop 3-display 9-exit\n");
scanf("%d",&ch);
}
}
This blog is all about technical questions in C, C++, data structures like linked lists, Binary trees, UNIX and other software developement issues which I faced.
Sunday, July 28, 2013
Stack implementation in C
Wednesday, July 24, 2013
BB10 Triple DES Crypto Sample App!!
In this post I am providing sample BB10 App for the crypto algorithm Triple DES. Here I have already provided the AES crypto algorithm for the BB10.
Limitations: as it is sample Application
Limitations: as it is sample Application
- It can encrypt maximum upto 40 char len string
- if you want more than 40 len, just change the code in encrypt method
- input should be multiples of SB_DES_BLOCK_SIZE (8)
- if input is not multiple of 8, you will get undefined values
Please comment below if you need any info or any bug you found.
Subscribe to:
Comments (Atom)
Popular Posts
-
A universally unique identifier ( UUID ) is an identifier standard used in software construction, standardized by the Open...
-
Recently I started working on Japser Studio professional for my new project Cloud to generate the reports. I was very new to all cloud ...
-
Below is C program for AVL Tree implementation. #include<stdio.h> #include<malloc.h> typedef struct bst { int info; int hei...
-
strcmp is another string library function which is used to compare two strings and returns zero if both strings are same , returns +ve valu...
-
One of the complex operation on binary search tree is deleting a node. Insertion is easy by calling recursive insertion. But deletion wont...
-
We have recently faced one tricky issue in AWS cloud while loading S3 file into Redshift using python. It took almost whole day to inde...
-
Object slicing: when a derived class object is assigned to a base class object. only base class data will be copied from derived class and...
-
We have faced lot of weird issues while loading S3 bucke t files into redshift. I will try to explain all issues what we faced. Before go...
-
Below code is to find the cube root of a given integer number with out using pow math library function. Its very simple and brute force...
-
Recently we faced one issue in reading messages from SQS in AWS cloud where we are processing same message multiple times. This issue we...