Created
February 2, 2014 15:55
-
-
Save willamesoares/8770406 to your computer and use it in GitHub Desktop.
Calculating the derivative of a polynomial function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Name: Derivada | |
Copyright: | |
Author: Soares Barroso, Willame | |
Date: 27/10/13 21:17 | |
Description: Calculation of the derivative of a polynomial function | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
main() | |
{ | |
printf("\n>>>>>>> Funcao Derivada de um Polinomio <<<<<<\n\n"); | |
float c[10],a[10]; | |
int grau,i; | |
printf("Grau do polinomio (polynomial's degree): "); | |
scanf("%d",&grau); | |
for(i=grau;i>=0;i--){ | |
printf("Coeficiente de x^%d: ",i); | |
scanf("%f",&c[i]); | |
} | |
for(i=0;i<=grau;i++){ | |
a[i]=c[i]*i; | |
} | |
printf("\nf'(x)= "); | |
for(i=grau;i>=1;i--){ | |
if(i-1==0) | |
printf("%.0f",a[i]); | |
else | |
printf("%.0fx^%d",a[i],i-1); | |
if(i!=1) | |
printf(" + "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment