Search This Blog

Thursday, October 13, 2011

Write a program that will provide a character string from command line which translates it into a number and evaluate and display its cube root

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  #include<math.h>
   4:  #include<stdlib.h>
   5:  void main(int argc,char *argv[])
   6:  {
   7:  float x;
   8:  if(argc<2)
   9:      {
  10:      printf("Insufficient number of arguments supplied:\n");
  11:      getch();
  12:      exit(0);
  13:      }
  14:  x=atof(argv[1]);
  15:  printf("cube root of %f is %f\n",x,pow(x,1.0/3.0));
  16:  getch();
  17:  }

No comments:

Post a Comment