Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jkjnknklkl #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions slll.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#include<stdio.h>
#include<stdlib.h>
struct node
{
int info;
struct node *ptr;
}*top,*top1,*temp;

void push(int data);
void pop();
void display();
void create();
int count=0;
void main()
{
int no,ch,e;
printf("\n 1-push");
printf("\n 2-pop");
printf("\n 3-exit");
printf("\n 4-display");

create();
while(1)
{
printf("\n enter the choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("enter the data");
scanf("%d",&no);
push(no);
break;
case 2:
pop();
break;
case 3:
exit(0);



break;
case 4:
display();
break;

}
}
}
void create()
{
top=NULL;
}

void push(int data)
{
if(top==NULL)
{
top=(struct node *) malloc(1*sizeof(struct node));
top ->ptr=NULL;
top ->info=data;
}
else
{
temp=(struct node*) malloc(1*sizeof(struct node));
temp->ptr=top;
temp->info=data;
top=temp;
}
count++;
}


void display()
{
top1=top;
if(top1==NULL)
{
printf("stack is empty");
return;
}
while(top1 !=NULL)
{
printf("%d",top1->info);
top1=top1->ptr;
}
}
void pop()
{
top1=top;
if(top1==NULL)
{
printf("empty stack");
return;
}
else
{
top1=top1->ptr;

printf("popped element is%d",top->info);
free(top);
top=top1;
count--;
}
}

56 changes: 56 additions & 0 deletions test1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
abstract class a{
abstract public void shape();


}
class rectangle extends a{
int dim1;
int dim2;
rectangle(int t,int p){
dim1=t;
dim2=p;
}
public void shape(){
int area=dim1*dim2;
System.out.println("rectangle area is"+area);
}
}
class circle extends a{
int dim1;
circle(int r){
dim1=r;
}
public void shape(){
double f=3.14;
double area=f*dim1*dim1;
System.out.println("circle area is"+area);
}
}
class triangle extends a{
int dim1;
int dim2;
triangle(int b,int h ){
dim1=b;
dim2=h;

}
public void shape(){
int area=dim1*dim2;
System.out.println("triangle area is"+area);
}
}
class test1{
a fig=new fig
a ref;
rectangle r=new rectangle(20,40);
circle c=new circle(20);
triangle t=new triangle(20,80);
public static void main(String args[]){
ref=r;
ref.shape();
ref=c;
ref.shape();
ref=t;
t.shape();
}
}