Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // sHorner
- //
- // Created by MacBook Pro on 18/10/2015.
- // Copyright © 2015 MacBook Pro. All rights reserved.
- //
- #include <stdio.h>
- #include "stdlib.h"
- int main(int argc, const char * argv[]) {
- int *a,n;
- int i=0;
- float x;
- double p;
- p=0;
- printf("Donner le degre de P: ");
- scanf("%d",&n);
- a = (int*)malloc((n+1)*sizeof(int));
- printf("Donner la valeur de x: ");
- scanf("%f",&x);
- printf("donner les coefficients du P:\n");
- while(i<n+1){
- printf("Donner le coefficient %d: ",n-i);
- scanf("%d",a+i);
- i++;
- }
- i=1;
- p = *(a+n);
- while (i<n+1) {
- p =p*x+ *(a+n-i);
- i++;
- }
- printf("le resultat est %f\n",p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement