Challenge

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

A = { 1,2,3,4} than A U B={1,2,3,4,5,6}

B= {2,3,4,5,6} where A intersection B ={2,3,4}

here we implemented this set theory function using various function like union and intersection.

/*
 ============================================================================
 Name        : Project1.c
 Author      : Ramlochan
 Version     :
 Copyright   : Your copyright notice
 Description : project1 Linked list concept
 ============================================================================
 */
#include<stdio.h>
#include<stdlib.h>
#include "list.h"							// included user defined header file list.h
int main()									// Main function is assigned
{
	int first_list_nodes = 0,second_list_nodes =0,first_list_items =0,second_list_items=0;	// integer type variable is declared
	printf("Enter the No of Nodes in first List :");		// Asking for no of nodes in 1st list
	fflush(stdout);											// clearing the cache memory
	scanf("%d",&first_list_nodes);							// reading the input given by the user and assign it to the first list nodes
	printf("Enter %d Elements:",first_list_nodes);  		// printing the entered elements of first list nodes
	for(int i=0;i<first_list_nodes;i++)						// for loop is used to initialized,test and make increment in the loop
	{
		fflush(stdout);										// clearing the cache memory
		scanf("%d",&first_list_items);						// Scanning the 1st list items
		head1 = insert_node(head1,first_list_items);		// inserting the node elements from 1st list items to head1
	}
	display_list(head1);									// display function is called to display the list of head1
	printf("\nEnter the No of Nodes in second List :");		// asking the no of nodes in second list
	fflush(stdout);											// clearing the cache memory
	scanf("%d",&second_list_nodes);							// scanning the second list nodes
	printf("Enter %d Elements:",second_list_nodes);			// printing the elements of second list nodes
	for(int i=0;i<second_list_nodes;i++)					// for loop is used to initialized,test, and increment in the loop
	{
		fflush(stdout);										// clearing the cache memory
		scanf("%d",&second_list_items);						// scanning the elements of 2nd list elements
		head2 =insert_node(head2,second_list_items);		// inserting the second list items to head2
	}
	display_list(head2);									// display function is used again to display the head list2
	res_union = get_union(head1,head2);						// union is calculated
	printf("\nHere is the result of Union :");				// printing the result of union
	display_list(res_union);								// display list for union
	res_intersection = get_intersection(head1,head2);			// intersection is calculated
	printf("\nHere is the result of intersection :");		// printing the result of intersection
	display_list(res_intersection);							// display list for intersection
}

Output:-

part 2

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.

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.