Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Program to compute x to the power n using while loop

Posted By: William Evans     Category: C Programming     Views: 27687

Program to compute x to the power n using while loop.

Code for Program to compute x to the power n using while loop in C Programming

   main()                                                      
   {                                                           
       int count, n;                                           
       float x, y;                                             
                                                               
       printf("Enter the values of x and n : ");               
       scanf("%f %d", &x, &n);                                 
       y = 1.0;                                                
       count = 1;               /* Initialisation */
/* LOOP BEGINs */
while ( count <= n) /* Testing */
{ y = y*x; count++; /* Incrementing */
} /* END OF LOOP */
printf("\nx = %f; n = %d; x to power n = %f\n",x,n,y); } Output Enter the values of x and n : 2.5 4 x = 2.500000; n = 4; x to power n = 39.062500 Enter the values of x and n : 0.5 4 x = 0.500000; n = 4; x to power n = 0.062500
  
Share: 


Didn't find what you were looking for? Find more on Program to compute x to the power n using while loop Or get search suggestion and latest updates.

William Evans
William Evans author of Program to compute x to the power n using while loop is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!