-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoly.c
More file actions
49 lines (49 loc) · 1003 Bytes
/
Copy pathpoly.c
File metadata and controls
49 lines (49 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<stdio.h>
void createpoly(int poly[],int d)
{
int i;
printf("enter the coefficient for \n");
for(i=d;i>=0;i--)
{
printf("degree %d element",i);
scanf("%d",poly[i]);
}
}
void display(int poly[],int d)
{
int i;
for(i=d;i>=0;i--)
{
if(i!=d && poly[i]>0)
printf("+");
printf("%dx%d",poly[i],i);
}
}
void main()
{
int poly1[50],d1,i,poly2[50],d2,polyres[50],dres;
printf("enter the degree of first polunomial");
scanf("%d",&d1);
createpoly(poly1,d1);
printf("enter the degree of 2nd polynomial");
scanf("%d",d2);
createpoly(poly2,d2);
if(d1>d2)
{
dres=d1;
}
else
{
dres=d2;
}
for(i=0;i<dres;i++)
{
polyres[i]=poly1[i]+poly2[i];
}
printf("the first poly is\n");
display(poly1,d1);
printf("second poly is\n");
display(poly2,d2);
printf("sum polynomial is\n");
display(polyres,dres);
}