Can someone debug my C codes and and the matrix tranpose..help pls

askmewhy25's Avatar, Join Date: Jan 2010
Go4Expert Member
Code:
//This program can evaluate a polynomial, solve for statistical algorithms
//and do matrix operations.
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>

//Start Program
main(){

    int selection;
    //Variables for Polynomial Evaluation    
    int n,w,x,y,z,QA;
    double poly[11],polysum;
    //Variables for Statistical Algorithms
    int SA,a,b,sum=0,data[10];
    float mean;
    double calc,sd;    
    //Variables for Matrix Operation
    int m1[3][3],i,j,k,m2[3][3],add[3][3],mult[3][3],r1,c1,r2,c2,MO;
    
    //Menu Selection Screen    
    do{
         system("cls");
         printf("Menu Selection Screen\n\n");
         printf("1 - Polynomial Evaluation\n");
         printf("2 - Statistical Algorithms\n");
         printf("3 - Matrix Operation\n");
         printf("4 - Exit\n");
         
         scanf("%d",&selection);
         switch(selection){
                           case 1://Polynomial Evaluation Screen
                                do{
                                   do{
                                      system("cls");
                                      printf("Polynomial Evaluation\n\n");
                                      printf("Enter the Order of Polynomial (max. 10): ");
                                      scanf("%d",&n);
                                      if(n>10||n<1){
                                                    system("cls");
                                                    printf("Invalid input. Please try again!!!\n");
                                                    printf("Please press the spacebar to continue!!");
                                                    getche();
                                                    }
                                      }while(n>10||n<1);
                                   y=n;
                                   z=n;
                                   for(w=0;w<y+1;w++){
                                       printf("Please enter the constant for X raised to the %dth: ",y--);
                                       scanf("%lf",&poly[w]);
                                       }
                                   printf("Please enter the constant for X raised to the 0th: ");
                                   scanf("%lf",&poly[10]);
                                   printf("Enter the value of X: ");
                                   scanf("%d",&x);   
                                   for(w=0;w<n+1;w++){
                                       polysum+=poly[w]*pow(x,n);
                                       n--;
                                       }
                                   polysum=polysum+poly[10];
                                   printf("The evaluated value of the %dth Order Polynomial  %lf\n", z, polysum);
                                   printf("Please press the spacebar to continue!!\n");
                                   getche();
                                   do{
                                      system("cls");
                                      printf("Do you want to repeat the computation?\n\n");
                                      printf("1 - Yes\n");
                                      printf("2 - No\n");
                                      scanf("%d", &QA);
                                      switch(QA){
                                                 case 1:
                                                      break;
                                                 case 2:
                                                      break;
                                                 default:
                                                         system("cls");
                                                         printf("Invalid input. Please try again!!!\n");
                                                         printf("Please press the spacebar to continue!!");
                                                         getche();
                                                         break;   
                                                 }
                                      }while(QA>2||QA<1);
                                   polysum=0;
                                   }while(QA==1);
                                   break;
                           case 2://Statistical Algorithms Screen
                                do{
                                   system("cls");
                                   printf("Statistical Algorithms\n\n");
                                   printf("1 - Mean\n");
                                   printf("2 - Standard Deviation\n");
                                   printf("3 - Summation of data\n");
                                   printf("4 - Go Back to Menu Selection Screen\n");
                                   
                                   scanf("%d", &SA);
                                   switch(SA){
                                              case 1:
                                                   do{
                                                      system("cls");
                                                      printf("Mean\n\n");
                                                      printf("Enter the Number of Data (max. 10): ");
                                                      scanf("%d", &b);
                                                      if(b>10||b<1){
                                                              system("cls");
                                                              printf("Invalid input. Please try again!!!\n");
                                                              printf("Please press the spacebar to continue!!");
                                                              getche();
                                                              }
                                                      }while(b>10||b<1);
                                                      for(a=0;a<b;a++){
                                                          printf("Enter the Actual Values of Data %d: ", a+1);
                                                          scanf("%d",&data[a]);
                                                          }
                                                      for(a=0;a<b;a++){
                                                          sum=sum+data[a];
                                                          }
                                                      mean=(float)sum/a;
                                                      printf("The Mean of the Data is %f\n",mean);
                                                      printf("Please press the spacebar to continue!!");
                                                      sum=0;
                                                      mean=0;
                                                      getche();
                                                      break;
                                              case 2:
                                                   do{
                                                      system("cls");
                                                      printf("Standard Deviation\n\n");
                                                      printf("Enter the Number of Data (max. 10): ");
                                                      scanf("%d", &b);
                                                      if(b>10||b<1){
                                                              system("cls");
                                                              printf("Invalid input. Please try again!!!\n");
                                                              printf("Please press the spacebar to continue!!\n");
                                                              getche();
                                                              }
                                                      }while(b>10||b<1);
                                                      for(a=0;a<b;a++){
                                                          printf("Enter the Actual Values of Data %d: ", a+1);
                                                          scanf("%d",&data[a]);
                                                             }
                                                      for(a=0;a<b;a++){
                                                          sum=sum+data[a];
                                                             }
                                                      mean=(float)sum/a;
                                                      for(a=0;a<b;a++){
                                                          calc+=pow((data[a]-mean),2);
                                                             }
                                                      sd=sqrt(calc/b);
                                                      printf("The Standard Deviation the Data is %lf\n",sd);
                                                      printf("Please press the spacebar to continue!!");
                                                      sum=0;
                                                      mean=0;
                                                      getche();
                                                      break;
                                              case 3:
                                                   do{
                                                      system("cls");
                                                      printf("Summation of Data\n\n");
                                                      printf("Enter the Number of Data (max. 10): ");
                                                      scanf("%d", &b);
                                                      if(b>10||b<1){
                                                              system("cls");
                                                              printf("Invalid input. Please try again!!!\n");
                                                              printf("Please press the spacebar to continue!!");
                                                              getche();
                                                              }
                                                      }while(b>10||b<1);
                                                      for(a=0;a<b;a++){
                                                          printf("Enter the Actual Values of Data %d: ", a+1);
                                                          scanf("%d",&data[a]);
                                                          }
                                                      for(a=0;a<b;a++){
                                                          sum=sum+data[a];
                                                          }
                                                      mean=(float)sum/a;
                                                      printf("The Summation of the Data is %d\n",sum);
                                                      printf("Please press the spacebar to continue!!");
                                                      sum=0;
                                                      mean=0;
                                                      getche();
                                                      break;
                                                 case 4:
                                                      break;
                                                 default:
                                                         system("cls");
                                                         printf("Invalid Input. Please try again!!!\n");
                                                         printf("Please press the spacebar to continue!!");
                                                         getche();
                                                         break;
                                              }
                                   }while(3>SA>1);           
                           case 3://Matrix Operation Screen
                                system("cls");
                                printf("Matrix Operation\n\n");
                                printf("1 - Matrix Addition\n");
                                printf("2 - Matrix Multiplication\n");
                                printf("3 - Transpose of Matrix\n");
                                printf("4 - Go Back to Menu Selection Screen\n");
                                scanf("%d", &MO);
                                switch(MO){
                                           case 1:
                                                printf("Matrix Addition\n\n");
                                                printf("Enter the number of rows of the first matrix (max 3): ");
                                                scanf("%d",&r1);
                                                printf("Enter the number of columns of the first matrix (max 3): ");
                                                scanf("%d",&c1);
                                                printf("Enter the number of rows of the second matrix (max 3): ");
                                                scanf("%d",&r2);
                                                printf("Enter the number of columns of the second matrix (max 3): ");
                                                scanf("%d",&c2);
                                                if(r2==c1){
                                                           printf("Enter rows and columns of First Matrix \n");
                                                           printf("Row wise\n\n");
                                                           for(i=0;i<r1;i++){
                                                                  printf("Enter the elements for row %d: ", i+1);
                                                                  for(j=0;j<c1;j++)
                                                                  scanf("%d",&m1[i][j]);
                                                                  }
                                                           printf("You have entered the First Matrix as follows:\n");
                                                           for(i=0;i<r1;i++){
                                                              for(j=0;j<c1;j++)
                                                              printf("%d\t",m1[i][j]);
                                                              printf("\n");
                                                              }
                                                           printf("Enter rows and columns of Second Matrix \n");
                                                           printf("Again row wise\n");
                                                           for(i=0;i<r2;i++){
                                                              printf("Enter the elements for row %d: ", i+1);
                                                              for(j=0;j<c2;j++)
                                                              scanf("%d",&m2[i][j]);
                                                              }
                                                           printf("You have entered the Second Matrix as follows:\n");
                                                           for(i=0;i<r2;i++){
                                                              for(j=0;j<c2;j++)
                                                              printf("%d\t",m2[i][j]);
                                                              printf("\n");
                                                              }
                                                           if(r1==r2&&c1==c2){
                                                              printf("Now we add both the above matrix \n");
                                                              printf("The result of the addition is as follows;\n");
                                                              for(i=0;i<r1;i++){
                                                                 for(j=0;j<c1;j++){
                                                                    add[i][j]=m1[i][j]+m2[i][j];
                                                                    printf("%d\t",add[i][j]);
                                                                 }
                                                                 printf("\n");
                                                              }
                                                           }
                                                           else{
                                                              printf("Addition cannot be done as rows or columns are not equal\n");
                                                           }
                                                }
                                                getche();
                                                break;
                                           case 2:
                                                printf("Matrix Multiplication\n\n");
                                                printf("Enter the number of rows of the first matrix (max 3): ");
                                                scanf("%d",&r1);
                                                printf("Enter the number of columns of the first matrix (max 3): ");
                                                scanf("%d",&c1);
                                                printf("Enter the number of rows of the second matrix (max 3): ");
                                                scanf("%d",&r2);
                                                printf("Enter the number of columns of the second matrix (max 3): ");
                                                scanf("%d",&c2);
                                                if(r2==c1){
                                                      printf("Enter rows and columns of First Matrix \n");
                                                      printf("Row wise\n\n");
                                                      for(i=0;i<r1;i++){
                                                         printf("Enter the elements for row %d: ", i+1);
                                                         for(j=0;j<c1;j++)
                                                         scanf("%d",&m1[i][j]);
                                                      }
                                                      printf("You have entered the First Matrix as follows:\n");
                                                      for(i=0;i<r1;i++){
                                                         for(j=0;j<c1;j++)
                                                         printf("%d\t",m1[i][j]);
                                                         printf("\n");
                                                         }
                                                      printf("Enter rows and columns of Second Matrix \n");
                                                      printf("Again row wise\n");
                                                      for(i=0;i<r2;i++){
                                                         printf("Enter the elements for row %d: ", i+1);
                                                         for(j=0;j<c2;j++)
                                                         scanf("%d",&m2[i][j]);
                                                         }
                                                      printf("You have entered the Second Matrix as follows:\n");
                                                      for(i=0;i<r2;i++){
                                                         for(j=0;j<c2;j++)
                                                         printf("%d\t",m2[i][j]);
                                                          printf("\n");
                                                         }
                                                      printf("Now we multiply both the above matrix \n");
                                                      printf("The result of the multiplication is as follows:\n");
                                                      for(i=0;i<r1;i++){
                                                         for(j=0;j<c2;j++){
                                                            mult[i][j]=0;
                                                            for(k=0;k<r1;k++){
                                                               mult[i][j]+=m1[i][k]*m2[k][j];
                                                            }
                                                         printf("%d\t",mult[i][j]);
                                                         }
                                                         printf("\n");
                                                      }
                                                      getche();
                                                }
                                                else{
                                                printf("Matrix multiplication cannot be done");
                                                }
                                                break;
                                           case 3:
                                                break;
                                           case 4:
                                                break;
                                           default:
                                                   system("cls");
                                                   printf("Invalid input. Please try again!!!\n");
                                                   printf("Please press the spacebar to continue!!");
                                                   getche();
                                                   break;
                                           }
                                break;
                           case 4://Exit
                                return 0;
                                break;
                           default:
                                   system("cls");
                                   printf("Invalid input. Please try again!!!\n");
                                   printf("Please press the spacebar to continue!!");
                                   getche();
                                   break;
                                   }
         }while(selection>=5 || SA==4 || QA==2);
         getche();
}//End Program

Last edited by shabbir; 24Jan2010 at 09:36.. Reason: Code blocks
0
kiddo's Avatar, Join Date: Apr 2009
Contributor
what compiler do you use?
is it logical error or syntax?

I'll try to check it....
0
askmewhy25's Avatar, Join Date: Jan 2010
Go4Expert Member
I am using bloodshed dev c++..i already couple of errors but i am having problem with reseting my standard deviation...

here is the updated version..
Code:
//This program can evaluate a polynomial, solve for statistical algorithms
//and do matrix operations.
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>

//Psalm 119:10-11
//10 I seek you with all my heart;
//do not let me stray from your commands.
//11 I have hidden your word in my heart
//that I might not sin against you.

//Start Program
main(){
       int selection;
       //Variables for Statistical Algorithms
       int SA,a,b,sum=0,data[10];
       float mean;
       double calc,sd;       
       //Variables for Matrix Operation
       int m1[3][3]={},i,j,k,m2[3][3]={},add[3][3]={},mult[3][3]={},r1,c1,r2,c2,MO;
       
       //Menu Selection Screen    
       do{
              system("cls");
              printf("Menu Selection Screen\n\n");
              printf("1 - Polynomial Evaluation\n");
              printf("2 - Statistical Algorithms\n");
              printf("3 - Matrix Operation\n");
              printf("4 - Exit\n");
         
              scanf("%d",&selection);
              switch(selection){
                                case 1:
                                     break;
                                case 2:
                                     do{
                                          sum=0;
                                          mean=0;
                                          sd=0;
                                          system("cls");
                                          printf("Statistical Algorithms\n\n");
                                          printf("1 - Mean\n");
                                          printf("2 - Standard Deviation\n");
                                          printf("3 - Summation of data\n");
                                          printf("4 - Go Back to Menu Selection Screen\n");
                                                                   
                                          scanf("%d", &SA);
                                          switch(SA){
                                                     case 1:
                                                          do{
                                                             system("cls");
                                                             printf("Mean\n\n");
                                                             printf("Enter the Number of Data (max. 10): ");
                                                             scanf("%d", &b);
                                                             if(b>10||b<1){
                                                                           system("cls");
                                                                           printf("Invalid input. Please try again!!!\n");
                                                                           printf("Please press the spacebar to continue!!");
                                                                           getche();
                                                                           }
                                                             }while(b>10||b<1);
                                                          for(a=0;a<b;a++){
                                                             printf("Enter the Actual Values of Data %d: ", a+1);
                                                             scanf("%d",&data[a]);
                                                             }
                                                          for(a=0;a<b;a++){
                                                             sum=sum+data[a];
                                                             }
                                                          mean=(float)sum/a;
                                                          printf("The Mean of the Data is %f\n",mean);
                                                          printf("Please press the spacebar to continue!!");
                                                          getche();
                                                          break;
                                                     case 2:
                                                          do{
                                                             system("cls");
                                                             printf("Standard Deviation\n\n");
                                                             printf("Enter the Number of Data (max. 10): ");
                                                             scanf("%d", &b);
                                                             if(b>10||b<1){
                                                                           system("cls");
                                                                           printf("Invalid input. Please try again!!!\n");
                                                                           printf("Please press the spacebar to continue!!\n");
                                                                           getche();
                                                                           }
                                                             }while(b>10||b<1);
                                                          for(a=0;a<b;a++){
                                                             printf("Enter the Actual Values of Data %d: ", a+1);
                                                             scanf("%d",&data[a]);
                                                             }
                                                          for(a=0;a<b;a++){
                                                             sum=sum+data[a];
                                                             }
                                                          mean=(float)sum/a;
                                                          for(a=0;a<b;a++){
                                                             calc+=pow((data[a]-mean),2);
                                                             }
                                                          sd=sqrt(calc/b);
                                                          printf("The Standard Deviation the Data is %lf\n",sd);
                                                          printf("Please press the spacebar to continue!!");
                                                          getche();
                                                          break;
                                                     case 3:
                                                          do{
                                                             system("cls");
                                                             printf("Summation of Data\n\n");
                                                             printf("Enter the Number of Data (max. 10): ");
                                                             scanf("%d", &b);
                                                             if(b>10||b<1){
                                                                           system("cls");
                                                                           printf("Invalid input. Please try again!!!\n");
                                                                           printf("Please press the spacebar to continue!!");
                                                                           getche();
                                                                           }
                                                             }while(b>10||b<1);
                                                          for(a=0;a<b;a++){
                                                             printf("Enter the Actual Values of Data %d: ", a+1);
                                                             scanf("%d",&data[a]);
                                                          }
                                                          for(a=0;a<b;a++){
                                                             sum=sum+data[a];
                                                             }
                                                          mean=(float)sum/a;
                                                          printf("The Summation of the Data is %d\n",sum);
                                                          printf("Please press the spacebar to continue!!");
                                                          getche();
                                                          break;
                                                     case 4:
                                                          main();
                                                          break;
                                                     default:
                                                             system("cls");
                                                             printf("Invalid Input. Please try again!!!\n");
                                                             printf("Please press the spacebar to continue!!");
                                                             getche();
                                                             break;
                                                     }
                                          }while(SA!=4); 
                                     break;
                                case 3:
                                     do{
                                          system("cls");
                                          printf("Matrix Operation\n\n");
                                          printf("1 - Matrix Addition\n");
                                          printf("2 - Matrix Multiplication\n");
                                          printf("3 - Transpose of Matrix\n");
                                          printf("4 - Go Back to Menu Selection Screen\n");
                                          scanf("%d", &MO);
                                          switch(MO){
                                                     case 1:
                                                          system("cls");
                                                          printf("Matrix Addition\n\n");
                                                          printf("Enter the number of rows of the first matrix (max 3): ");
                                                          scanf("%d",&r1);
                                                          printf("Enter the number of columns of the first matrix (max 3): ");
                                                          scanf("%d",&c1);
                                                          printf("Enter the number of rows of the second matrix (max 3): ");
                                                          scanf("%d",&r2);
                                                          printf("Enter the number of columns of the second matrix (max 3): ");
                                                          scanf("%d",&c2);
                                                          if(r2==c1){
                                                                     printf("Enter rows and columns of First Matrix \n");
                                                                     printf("Row wise\n\n");
                                                                     for(i=0;i<r1;i++){
                                                                        printf("Enter the elements for row %d: ", i+1);
                                                                        for(j=0;j<c1;j++)
                                                                           scanf("%d",&m1[i][j]);
                                                                     }
                                                                     printf("You have entered the First Matrix as follows:\n");
                                                                     for(i=0;i<r1;i++){
                                                                        for(j=0;j<c1;j++)
                                                                        printf("%d\t",m1[i][j]);
                                                                        printf("\n");
                                                                     }
                                                                     printf("Enter rows and columns of Second Matrix \n");
                                                                     printf("Again row wise\n");
                                                                     for(i=0;i<r2;i++){
                                                                        printf("Enter the elements for row %d: ", i+1);
                                                                        for(j=0;j<c2;j++)
                                                                        scanf("%d",&m2[i][j]);
                                                                     }
                                                                     printf("You have entered the Second Matrix as follows:\n");
                                                                     for(i=0;i<r2;i++){
                                                                       for(j=0;j<c2;j++)
                                                                       printf("%d\t",m2[i][j]);
                                                                       printf("\n");
                                                                     }
                                                                     if(r1==r2&&c1==c2){
                                                                        printf("Now we add both the above matrix \n");
                                                                        printf("The result of the addition is as follows;\n");
                                                                        for(i=0;i<r1;i++){
                                                                           for(j=0;j<c1;j++){
                                                                              add[i][j]=m1[i][j]+m2[i][j];
                                                                              printf("%d\t",add[i][j]);
                                                                           }
                                                                           printf("\n");
                                                                        }
                                                                     }
                                                                     else{
                                                                     printf("Addition cannot be done as rows or columns are not equal\n");
                                                                     }
                                                          }
                                                          printf("Please press the spacebar to continue!!");
                                                          getche();
                                                          break;
                                                     case 2:
                                                          system("cls");
                                                          printf("Matrix Multiplication\n\n");
                                                          printf("Enter the number of rows of the first matrix (max 3): ");
                                                          scanf("%d",&r1);
                                                          printf("Enter the number of columns of the first matrix (max 3): ");
                                                          scanf("%d",&c1);
                                                          printf("Enter the number of rows of the second matrix (max 3): ");
                                                          scanf("%d",&r2);
                                                          printf("Enter the number of columns of the second matrix (max 3): ");
                                                          scanf("%d",&c2);
                                                          if(r2==c1){
                                                                     printf("Enter rows and columns of First Matrix \n");
                                                                     printf("Row wise\n\n");
                                                                     for(i=0;i<r1;i++){
                                                                        printf("Enter the elements for row %d: ", i+1);
                                                                        for(j=0;j<c1;j++)
                                                                        scanf("%d",&m1[i][j]);
                                                                     }
                                                                     printf("You have entered the First Matrix as follows:\n");
                                                                     for(i=0;i<r1;i++){
                                                                        for(j=0;j<c1;j++)
                                                                        printf("%d\t",m1[i][j]);
                                                                        printf("\n");
                                                                        }
                                                                     printf("Enter rows and columns of Second Matrix \n");
                                                                     printf("Again row wise\n");
                                                                     for(i=0;i<r2;i++){
                                                                        printf("Enter the elements for row %d: ", i+1);
                                                                        for(j=0;j<c2;j++)
                                                                        scanf("%d",&m2[i][j]);
                                                                     }
                                                                     printf("You have entered the Second Matrix as follows:\n");
                                                                     for(i=0;i<r2;i++){
                                                                       for(j=0;j<c2;j++)
                                                                       printf("%d\t",m2[i][j]);
                                                                       printf("\n");
                                                                       }
                                                                     printf("Now we multiply both the above matrix \n");
                                                                     printf("The result of the multiplication is as follows:\n");
                                                                     for(i=0;i<r1;i++){
                                                                        for(j=0;j<c2;j++){
                                                                           mult[i][j]=0;
                                                                           for(k=0;k<r1;k++){
                                                                             mult[i][j]+=m1[i][k]*m2[k][j];
                                                                           }
                                                                           printf("%d\t",mult[i][j]);
                                                                        }
                                                                        printf("\n");
                                                                     }
                                                          }
                                                                     else{
                                                                          printf("Matrix multiplication cannot be done");
                                                                          }
                                                                     printf("Please press the spacebar to continue!!");
                                                                     getche();
                                                                     break;
                                                     case 3:
                                                          system("cls");
                                                          printf("Transpose of Matrix\n\n");
                                                          printf("Enter the number of rows of the matrix (max 3): ");
                                                          scanf("%d",&r1);
                                                          printf("Enter the number of columns of the matrix (max 3): ");
                                                          scanf("%d",&c1);
                                        
                                                          printf("Enter rows and columns of Matrix \n");
                                                          printf("Row wise\n\n");
                                                          for(i=0;i<r1;i++){
                                                             for(j=0;j<c1;j++){
                                                                scanf("%d",&m1[i][j]);
                                                                m2[j][i]=m1[i][j];
                                                                }
                                                          }
                                                          printf("You have entered the First Matrix as follows:\n");
                                                          for(i=0;i<r1;i++){
                                                             for(j=0;j<c1;j++)
                                                             printf("%d\t",m1[i][j]);
                                                             printf("\n");
                                                          }
                                                          printf("Transpose of Matrix is:\n");
                                                          for(i=0;i<c1;i++){
                                                             for(j=0;j<r1;j++)
                                                             printf("%d\t",m2[i][j]);
                                                             printf("\n");
                                                          }
                                                          printf("Please press the spacebar to continue!!");
                                                          getche();
                                                          break;
                                                     case 4:
                                                          main();
                                                          break;
                                                     default:
                                                             system("cls");
                                                             printf("Invalid input. Please try again!!!\n");
                                                             printf("Please press the spacebar to continue!!");
                                                             getche();
                                                             break;
                                                     }
                                        }while(MO!=4);                
                                     break;
                                case 4:
                                     return 0;
                                     break;
                                default:
                                        system("cls");
                                        printf("Invalid input. Please try again!!!\n");
                                        printf("Please press the spacebar to continue!!");
                                        getche();
                                        break;
                                }
         }while(selection>4 || selection<=0);
}

Last edited by shabbir; 25Jan2010 at 18:49.. Reason: Code blocks
0
askmewhy25's Avatar, Join Date: Jan 2010
Go4Expert Member
btw kiddo if also you have time can you also dubug my polynomial program..only if you can
Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>

main(){
       double poly[11]={};
       double polysum;
       int w, v, x, y, n, z,QA;
       
       do{
          do{
             system("cls");
             printf("Polynomial Evaluation\n\n");
             printf("Enter the Order of Polynomial (max. 10): ");
             scanf("%d",&n);
             if(n>10||n<1){
                           system("cls");
                           printf("Invalid input. Please try again!!!\n");
                           printf("Please press the spacebar to continue!!");
                           getche();
                           }
             }while(n>10||n<1);
             y=n+1;
             z=n;
             v=n;
             while(y!=0){
                         printf("Please enter the constant for X raised to the %dth: ", z);
                         scanf("%lf",&poly[z]);
                         y--;
                         z--;
                         }
             printf("Enter the value of X: ");
             scanf("%d",&x);   
             for(w=0;w<n+1;w++){
                                polysum+=poly[w]*pow(x,n);
                                n--;
                                }
             polysum=polysum+poly[0];
             printf("The evaluated value of the %dth Order Polynomial  %lf\n", v, polysum);
             printf("Please press the spacebar to continue!!\n");
             getche();
             do{
                system("cls");
                printf("Do you want to repeat the computation?\n\n");
                printf("1 - Yes\n");
                printf("2 - No\n");
                scanf("%d", &QA);
                switch(QA){
                           case 1:
                                break;
                           case 2:
                                break;
                           default:
                                   system("cls");
                                   printf("Invalid input. Please try again!!!\n");
                                   printf("Please press the spacebar to continue!!");
                                   getche();
                                   break;   
                           }
                }while(QA>2||QA<1);
                polysum=0;
             }while(QA==1);
}

Last edited by shabbir; 25Jan2010 at 18:49.. Reason: Code blocks