Skip to content

Commit 0a7700a

Browse files
committed
trying gitignore
1 parent 506f440 commit 0a7700a

File tree

3 files changed

+142
-0
lines changed

3 files changed

+142
-0
lines changed

linkedlist.c

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
struct NODE
5+
{
6+
int data;
7+
struct NODE *next;
8+
};
9+
10+
typedef struct NODE *node;
11+
12+
void getnode(node *n)
13+
{
14+
*n = (struct NODE *)malloc(sizeof(struct NODE));
15+
}
16+
17+
void insert(node *n, int x)
18+
{
19+
node temp = *n;
20+
getnode(n);
21+
(*n)->data = x;
22+
(*n)->next = temp;
23+
}
24+
25+
void insertend(node *n, int x)
26+
{
27+
while(*n != NULL)
28+
n = &((*n)->next);
29+
getnode(n);
30+
(*n)->data = x;
31+
(*n)->next = NULL;
32+
}
33+
34+
void display(node *n)
35+
{
36+
printf("\n");
37+
while(*n != NULL)
38+
{
39+
printf("%d ", (*n)->data);
40+
n = &((*n)->next);
41+
}
42+
printf("\n");
43+
return;
44+
}
45+
46+
int delete(node *n, int x)
47+
{
48+
int count = 0;
49+
while(*n != NULL)
50+
{
51+
if ((*n)->data == x)
52+
{
53+
node temp = *n;
54+
*n = (*n)->next;
55+
free(temp);
56+
count++;
57+
}
58+
else
59+
{
60+
n = &((*n)->next);
61+
}
62+
}
63+
return count;
64+
}
65+
66+
int main()
67+
{
68+
node a = NULL;
69+
70+
while (1)
71+
{
72+
int n;
73+
printf("1 - insert, 2 - display, 3 - delete\n");
74+
scanf("%d", &n);
75+
76+
if (n == 1)
77+
{
78+
int d;
79+
printf("Enter int: ");
80+
scanf("%d", &d);
81+
insertend(&a, d);
82+
}
83+
else if (n == 2)
84+
{
85+
display(&a);
86+
}
87+
else if (n == 3)
88+
{
89+
int d;
90+
printf("Enter int: ");
91+
scanf("%d", &d);
92+
printf("%d elements deleted\n", delete(&a, d));
93+
}
94+
else
95+
{
96+
return 0;
97+
}
98+
}
99+
}

ponder.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <stdio.h>
2+
3+
int const MAX = 4;
4+
5+
int main ()
6+
{
7+
char *names[] = {
8+
"Zara Ali a",
9+
"Hina Alia",
10+
"Nuha Ali",
11+
"Sara Ali"
12+
};
13+
14+
char *a = "fuck c";
15+
16+
printf("%s\n", a);
17+
printf("%lu\n", sizeof(a));
18+
19+
printf("%d\n", sizeof(names));
20+
printf("%d\n", sizeof(names[1]));
21+
22+
int i = 0;
23+
for (i = 0; i < MAX; i++)
24+
{
25+
printf("Value of names[%d]=%s\n",i,names[i]);
26+
}
27+
return 0;
28+
}

ponder2.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <stdio.h>
2+
3+
int main ()
4+
{
5+
int a[][3] = {
6+
1,2,3,4,
7+
5,6,7,8,
8+
9,0,0,0
9+
};
10+
11+
printf("%d\n", sizeof(a));
12+
printf("%d\n", sizeof(a[1]));
13+
14+
return 0;
15+
}

0 commit comments

Comments
 (0)