All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Q:- In this project, interfaces for mathematical Set Theory are implemented using C programming language. User can give the input like two list of data and this program will give the output as the union and intersection of these two lists. Ans: Aim: To write code for interfaces for mathematical Set Theory are implemented…
Chandrakumar ADEPU
updated on 11 Jan 2023
Q:- In this project, interfaces for mathematical Set Theory are implemented using C programming language. User can give the input like two list of data and this program will give the output as the union and intersection of these two lists.
Ans:
Aim: To write code for interfaces for mathematical Set Theory are implemented using C programming language. User can give the input like two list of data and this program will give the output as the union and intersection of these two lists.
Code:
/*
* Project_1.c
*/
#include
#include
// A structure of Linked List node
struct node {
int data;
struct node *next;
}*LLOne, *LLTwo, *unionLL, *intersectionLL;
void initialize()
{
LLOne = LLTwo = NULL;
}
//Given a Inserts a node in front of a singly linked list.
void insert(struct node **head, int num)
{
struct node* newNode = (struct node*)malloc(sizeof(struct node));
// Create a new Linked List node
newNode->data = num;
// Next pointer of new node will point to head node of linked list
newNode->next = *head;
//make new node as new head of linked list
*head = newNode;
}
//Prints a linked list from head node till tail node
void printlinkedlist (struct node *nodeptr)
{
while (nodeptr!= NULL){
printf("%d", nodeptr->data);
nodeptr = nodeptr->next;
if (nodeptr != NULL)
printf("-->");
}
}
//Returns the union of two given linked list
struct node* findunion(struct node *LLOne, struct node *LLTwo)
{
unionLL = NULL;
//Prints a linked list from head node till tail node
struct node *temp = LLOne;
while (temp != NULL)
{
insert(&unionLL, temp->data);
temp = temp->next;
}
// Insert those nodes of LLTwo which is not present in LLOne
while (LLTwo!= NULL)
{
if(!search(LLOne,LLTwo->data))
{
insert(&unionLL, LLTwo->data);
}
LLTwo = LLTwo->next;
}
return unionLL;
}
// Searches an element in Linked List by linearly traversing from head to tail
int search(struct node *head, int num)
{
while (head != NULL)
{
if (head->data == num)
{
return 1;
}
head = head->next;
}
return 0;
}
//Returns the Linked List which contains common nodes of two given linked list
struct node* intersection(struct node *LLOne, struct node *LLTwo)
{
intersectionLL = NULL;
//Search every element of LLOne in LLTwo, If found then add it to intersection List
while(LLOne != NULL)
{
if(search(LLTwo, LLOne->data))
{
insert(&intersectionLL, LLOne->data);
}
LLOne = LLOne->next;
}
return intersectionLL;
}
int main(){
int i, LLOnecount, LLTwocount, temp;
initialize();
// Declaring or assign the input elements if the first linked list
printf(" Enter the no.of node is the first list: \n");
fflush (stdout);
scanf("%d",&LLOnecount);
printf("Enter the %d integers of the nodes\n",LLOnecount);
fflush(stdout);
for (i=0; i
Output:
-------------------------------------------------------************************------------------------------------------------
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week - 4
Implement control logic of a “washing machine” using Stateflow as per given sequence: If the power supply is available, the system gets activated If the Water supply is not available, stop the process & indicate through LED Soaking time should be 200s followed by Washing time of 100s. Then rinsing…
29 Sep 2023 07:17 AM IST
Project 2 - V&V SW Analysis II
Q:- 1. Perform Static Code Review Analysis for “C:\**\LDRA_workarea\Examples\C_Testbed_examples\Testrain\Testrain.c” Generate Code review report and upload them. Ans: Aim: To gernetate the code review report and upload them. Steps: Steps for White box testing:- Source ->…
18 Aug 2023 01:16 PM IST
Project 1 - V&V SW Analysis - I
Q:- Write a Test plan to test features of a new mobile phone (Blackbox test) that needs to be implemented based on the following requirements. (The product is still under development stage and is yet to be UA (User Acceptance ) tested…
12 Jul 2023 03:17 AM IST
Project 2 - Measuring distance of an object using ultrasonic sensor (HC-SR04)
PROJECT-2: Aim: To write a program to measure the distance using ultasonic sensot Schematic Diagram: Steps of Programming ATmega16 microcontroller needs to transmit at least 10 us trigger pulse to the HC-SR04 Trig Pin. After getting a trigger pulse, HC-SR04 automatically sends eight 40 kHz sound waves and the microcontroller…
24 Jun 2023 09:50 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.