Challenge

Project 1 - Creation of user defined data type to implement the user interfaces for working with ‘Set’ (Mathematical Set theory) using Linked List

/* Creation of user defined data type to implement the user interfaces for working with
‘Set’ (Mathematical Set theory) using Linked List *

#include "list.h" // user defined head file

int main()
{
int i, first_list_nodes = 0, second_list_nodes = 0,
first_list_items = 0, second_list_items = 0;
printf("Enter the number of nodes in first list: "); //print the nodes in the list
fflush (stdout); // clear the catch memory
scanf ("%d", &first_list_nodes); // input from the console/user i.e. 4
printf("\nEnter %d the elements:", first_list_nodes); // getting the number in the list
for (i=0; i<first_list_nodes;i++)
{
fflush (stdout);
scanf("%d", &first_list_items); // getting the data at the run time 2,3,4,5
head1 = insert_node(head1,first_list_items); // inserting the data in the list
}
printf ("\n First List Items: \n");
display_list(head1); // displaying the first list

printf("\nEnter the number of nodes in second list: "); //print the nodes in the list
fflush (stdout); // clear the catch memory
scanf ("%d", &second_list_nodes); // input from the console/user i.e. 4
printf("\nEnter %d the elements:", second_list_nodes); // getting the number in the list
for (i=0; i<second_list_nodes;i++)
{
fflush (stdout);
scanf("%d", &second_list_items); // getting the data at the run time 3,4,5,6
head2 = insert_node(head2,second_list_items); // inserting the data in the list
}
printf ("\n Second List Items: \n");
display_list(head2); // displaying the first list

res_union = get_union (head1, head2); // assign result of union function to the variable
printf("Here is the result of union: ");
display_list(res_union); // display the result of union function

res_intersection = get_intersection (head1, head2); // assign result of union function to the variable
printf("Here is the result of intersection: ");
display_list(res_intersection); // display the result of intersection function

}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.