Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please make this Output C language visual studios CIS27-Data Structures: Homewor

ID: 3729218 • Letter: P

Question

Please make this Output C language visual studios
CIS27-Data Structures: Homework #4 ~ Page 2 of 7 1. Coding Assignment Exercise #1 1. Write a menu program to have the display below, CIS 27c Programming Laney College Your Name Assignment Information- Assignment Number: Homework 04, Written by: Submitted Date: coding Assignment -- Exercise #1 Your Name Due Date 2. You are going to work with polynomials that have fraction as coefficients and integers as powers/exponents The polynomials will be created as linked lists with the information and specifications given below (you should attach YourFirstName in full and YourLastName initial at the end of the structures and functions below Using my name as examples and discussed in class). /* Homework 4 Preparation Start*/ struct FractionTuan f int num int denom; h: struct PolyTermTuan ( int exp struct FractionTuan coePtr struct PolyNode Tuans f struct PolyTermTuanN ptPtr struct PolyNodeTuanN* next; 2: typedef struct FractionTuanN FractionTuan; typedef struct PolyTersTuans PolyTernTuanj typedef struct PolyNode Tuans Polyode Tuan typedef FractionTuan FractionPtrTuan; typedef ermtuan Po ·

Explanation / Answer

The following c program demonstrates the polynomial operations using the menu options:

#include <stdio.h>
#include <conio.h>
#include <math.h>

typedef struct node
{ int p1;
float coef;
struct node *n1;
}node;

node * insert(node *h1,int p1,float coef1);
node * create();
node * add(node *a,node *b);
node * mul(node *a,node *b);
float eval(node *a,float e);
void print(node *h1);
node * del(node *n1);


node * insert(node *h1,int p1,float coef1)
{  
node *s,*t;
  
s=(node*) malloc(sizeof(node));
s->p1=p1;
s->coef=coef1;
s->n1=NULL;
if(h1==NULL)
{
h1=s;
h1->n1=h1;
return(h1);
}
if(s->h1->p1)
{
s->n1=h1->n1;
h1->n1=s;
h1=s;
return(h1);
}
if(p1==h1->p1)
{
h1->coef=h1->coef+coef1;
return(h1);
}

t=h1;
while(t->n1!=h1 && p1>=t->n1->p1)
t=t->n1;
if(s->p1==t->p1)
t->coef=t->coef+coef1;
else
{
s->n1=t->n1;
t->n1=s;
}
return(h1);
}


node * create()
{
int n,i,p1;
float coef1;
node *h1=NULL;
printf(" Enter the number of Terms:");
scanf("%d",&n);
printf(" enter the term as a pair of (p1,coef): ");
for(i=1;i<=n;i++)
{ scanf("%d%f",&p1,&coef1);
h1=insert(h1,p1,coef1);
}
return(h1);
}

node * add(node *a,node *b)
{
node *p;
node *h1=NULL;
float coef;

p=a->n1;
do
{
h1=insert(h1,p->p1,p->coef);
p=p->n1;
} while(p!=a->n1);
p=b->n1;
do
{
h1=insert(h1,p->p1,p->coef);
p=p->n1;
} while(p!=b->n1);
return(h1);
}

node * mul(node *a,node *b)
{ node *h13,*h14;
node *h1=NULL;

h14=b->n1;
do
{ h13=h1->n1;
do
{
// for(p=h13;p!=NULL;p=p->n1)
h1=insert(h1,h13->a+h14->a,h13->coef * h14->coef);
h13=h13->n1;
}while(h13!=a->n1);
h14=h14->n1;
}while(h14!=b->n1);
return(h1);
}


float eval(node *a,float e)
{ float v1=0.00;
node *p10;
p10=a->n1;
do
{  
v1=v1+p10->coef * pow(e,p10->p1);
p10=p10->n1;
}while(p10!=h1->n1);
return(v1);
}

void print( node *h1)
{ node *p;
p=h1->n1;
printf(" ");
do
{
printf("%f%d ",p->coef,p->p1);
p=p->n1;
}while(p!=h1->n1);
}

node * del(node *p1)
{

free(p1);
}

void main()
{ node *p1,*p2,*p3;
int option;
float v2,z;
p1=p2=p3=NULL;
clrscr();
do
{ printf(" 1)Create first polynomial");
printf(" 2)Create second polynomial");
printf(" 3)Print first polynomial");
printf(" 4)Print second polynomial");
printf(" 5)Add 6)Multiply 7)Evaluate the Polynomial 8)Delete 9)Quit");
printf(" Enter Your Choice: ");
scanf("%d",&option);
switch(option)
{

case 1: p1=create();
break;
case 2: p2=create();
break;
case 3: print(p1);
break;

case 4: print(p2);
break;
case 5: p3=add(p1,p2);
print(p3);
break;
case 6: p3=mul(p1,p2);
print(p3);
break;
case 7: printf(" Enter the value of z ");
scanf("%f",&z);
v2=eval(p1,z);
printf(" Computed value is =%f",v2);
break;

case 8: p3=del(p1);
break;
}
}while(option!=8);
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote