C program to evaluate: r= 1/3{x+3(x^3)+9(x^9)}"); 1/2{x+2(x^2)+4(x^4)}");

Leave a Comment



#include<stdio.h>     
#include<math.h>
//float power(float,int);
int main()
{
             double x,res;
             int choice;
             printf("Enter your choice\n");
             printf("1: For r= 1/3{x+3(x^3)+9(x^9)}\n\n");
             printf("2: For r= 1/2{x+2(x^2)+4(x^4)}\n\n");
             scanf("%d",&choice);
             printf("Enter the value of : X   \n");
             scanf("%lf",&x);


             /*SWITCH-CASE BEGINS*/

             switch(choice)
             {
                        case 1:
                                                res=(x+(3*pow(x,3))+(9*pow(x,9)))/3;
                                                printf("r = 1/3{%lf+3(%lf^3)+9(%lf^9)}",x,x,x);
                                                break;
                        case 2:
                                                res=(x+(2*pow(x,2))+(4*pow(x,4)))/3;
                                                printf("r = 1/2{%lf+2(%lf^2)+4(%lf^4)}",x,x,x);
                                                break;
             }
             /*SWITCH-CASE ENDS*/


             printf("The result of the operation is %lf \n",res);

             getch();
             return 0;
}

0 comments:

Post a Comment