-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUntitled2.cpp
More file actions
79 lines (79 loc) · 1.25 KB
/
Untitled2.cpp
File metadata and controls
79 lines (79 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<stdio.h>
#include<process.h>
#include<stdlib.h>
#define MAX 20
int top=-1,stack[MAX];
void push();
void traverse();
main()
{
int ch;
while(1)
{
printf("***Student Detail***");
printf("\n1.Enter student Detail\n2.search detail\n3.Exit\n");
printf("Please enter your choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1:
push();
break;
case 2:
traverse();
break;
case 3:
exit(0);
default:
printf("\nYou entered a wrong choice???\n");
}
}
}
void push()
{
struct student
{
int roll;
char name[20];
char branch[10];
int ph[10];
};
struct student stack[MAX];
int i;
if(top==MAX-1)
{
printf("\nStudent List is Full??\n");
}
else
{
for(i=0;i<MAX;i++)
{
printf("\nRoll:");
scanf("%d",&stack[i].roll);
printf("\nName:");
scanf("%s",&stack[i].name);
printf("\nBranch:");
scanf("%s",&stack[i].branch);
printf("\nPhone:");
scanf("%d",stack[i].ph);
top=top+1;
struct student stack[top]=stack[i];
}
}
}
void traverse()
{
int i;
if(top==-1)
{
printf("\n***Student List is Empty***\n");
}
else
{
printf("\n***Student Detail***\n");
for(i=0;i>=0;i--)
{
printf("\nRoll:%d\nName:%s\nBranch:\nPhone:%d",stack[i].roll,stack[i].name,stack[i].branch,stack[i].ph);
}
}
}