The need:
The need is nothing but to find k'th root of a number.
The code:
----------------------------------------------------------------
The Approach:
The approach is very simple. Lets apply simple math
If y^k = x
then y = x^(1/k)
and the problem is solved because we have built-in pow() function for a power.
The need is nothing but to find k'th root of a number.
The code:
----------------------------------------------------------------
#include<stdio.h> #include<math.h> main() { printf ("*********a program to find k'th root of x ....\n\n"); char c; float i,j,k,m; do { printf ("To get k'th root of x ....\n"); printf ("type the values .....\n\n"); printf ("x= "); scanf("%f",&i); printf ("k= "); scanf("%f",&k); j=pow(i,(1/k)); printf("\n %dth root of%f = %f\n\n\n",(int)k,i,j); printf("do you want to try more? y/n \t"); fflush(stdin); c=getchar(); }while(c=='y'); }----------------------------------------------------------------
The Approach:
The approach is very simple. Lets apply simple math
If y^k = x
then y = x^(1/k)
and the problem is solved because we have built-in pow() function for a power.
No comments:
Post a Comment
feel free to ask your doubts... if any
you can post your doubts on
www.facebook.com/programsimply