-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path18.c
More file actions
31 lines (29 loc) · 696 Bytes
/
18.c
File metadata and controls
31 lines (29 loc) · 696 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
#include <stdio.h>
int main()
{
int n, i, k, a[20], b[20], c[20];
printf("enter the degree of the polynomial");
scanf("%d", &n);
printf("enter the first polynomial\n");
for (i = n, k = 0; i >= 0; i--, k++)
{
printf("enter the coeffient of x^%d", i);
scanf("%d", &a[k]);
}
printf("enter the second polynomial\n");
for (i = n, k = 0; i >= 0; i--, k++)
{
printf("enter the coeffient of x^%d", i);
scanf("%d", &b[k]);
}
for (k = 0; k <= n; k++)
{
c[k] = a[k] + b[k];
}
printf("the sum is\n");
for (i = n, k = 0; i >= 0; i--, k++)
{
printf("%dx^%d+", c[k], i);
}
return 0;
}