PROGRAM 9
PROGRAM 9
Develop a Program in C for the following operations on Singly Circular Linked List (SCLL)
with header nodes
a) Represent and Evaluate a Polynomial P(x,y,z) = 6x2y2z-4yz5+3x3yz+2xy5z-2xyz3
b) Find the sum of two polynomials POLY1(x,y,z) and POLY2(x,y,z) and store the result in
POLYSUM(x,y,z)
Support the program with appropriate functions for each of the above operations
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
struct node
{
int co,ex,ey,ez;
struct node *link;
};
typedef struct node NODE;
NODE *createnode(int,int,int,int);
NODE *attachnode(NODE*,NODE*);
NODE *readpoly();
void display(NODE*);
void evaluate(NODE*);
NODE *addpoly(NODE*,NODE*,NODE*);
int main()
{
int ch;
NODE *p1,*p2,*p3;
p3=(NODE*)malloc(sizeof(NODE));
p3->link=p3;
while(1)
{
printf("1.represent and evaluate 2.add two polynomial 3.exit\n");
printf("enter choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("enter a polynomial\n");
p1=readpoly();
display(p1);
evaluate(p1);
break;
case 3:exit(0);
default:printf("invalid choice\n");
break;
}
}
}