Dsa Lab Manual
Dsa Lab Manual
h>
#include <stdlib.h>
strict Day
char * activity;
};
}
}
printf("\n");
free(calendar[i].dayName);
free(calendar[i].activity);
}int main()
int size;
if (calendar == NULL)
{
return 1;
read(calendar, size);
display(calendar, size);
freeMemory(calendar, size);
free(calendar);return 0;
Output:
Enter the number of days in the week: 7Enter details for Day 1:
Enter the activity for the day: LearningEnter details for Day 2:
Enter the activity for the day: CodingEnter details for Day 3:
Enter the activity for the day: TestingEnter details for Day 4:
Enter the activity for the day: DebuggingEnter details for Day 5:
Enter the activity for the day: PublishingEnter details for Day 6:
Enter the activity for the day: MarketingEnter details for Day 7:
Day 1:
Date: 1
Activity: LearningDay 2:
Date: 2
Activity: CodingDay 3:
Date: 3
Activity: TestingDay 4:
Date: 4
Activity: DebuggingDay 5:
Date: 5
Activity: PublishingDay 6:
Activity: MarketingDay 7:
Date: 7
Activity: Earning
#include<stdio.h>
int c = 0, m = 0, i = 0, j = 0, k, flag = 0;
void stringmatch()
if (str[m] == pat[i])
i++;
m++;
if (pat[i] == '\0')
flag = 1;
res[j] = rep[k];
i = 0;
c = m;
Else
res[j] = str[c];
j++;
c++;
m = c;
i = 0;
res[j] = '\0';
void main()
gets(str);
gets(pat);
gets(rep);
stringmatch();
if (flag == 1)
printf("\nThe string after pattern match and replace is: \n %s ", res);
else
Output:
#include<stdio.h>
#include<stdlib.h>
#define MAX 3
int s[MAX];
int pop();
void palindrome();
while (1)
printf("\n\n\n\n~~~~~~Menu~~~~~~ : ");
printf("\n=>4.Display ");
printf("\n=>5.Exit");
switch (choice)
case 1:
break;
case 2:
item = pop();
if (item != -1)
break;
case 3:
palindrome();
break;
case 4:
display();
break;
case 5:
exit(1);
default:
break;
if (top == MAX - 1) {
printf("\n~~~~Stack overflow~~~~");
return;
}
top = top + 1;
s[top] = item;
int pop() {
int item;
if (top == -1)
printf("\n~~~~Stack underflow~~~~");
return -1;
item = s[top];
top = top - 1;
return item;
void display()
int i;
if (top == -1) {
printf("\n~~~~Stack is empty~~~~");
return;
int flag = 1, i;
flag = 0;
break;
if (flag == 1) {
Else