Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

PROGRAM SHOWING THE USE OF A CAST

Posted By: Rambert Fischer     Category: C Programming     Views: 1660

PROGRAM SHOWING THE USE OF A CAST.

Code for PROGRAM SHOWING THE USE OF A CAST in C Programming

main()                                                      
   {                                                           
       float  sum ;                                            
       int    n ;                                              
                                                               
       sum = 0 ;                                               
                                                               
       for( n = 1 ; n <= 10 ; ++n )                            
       {                                                       
          sum = sum + 1/(float)n ;                             
          printf("%2d  %6.4f\n", n, sum) ;                     
       }                                                       
   }                                                           
                                                               
Output                                                      
                                                               
    1  1.0000                                                  
    2  1.5000                                                  
    3  1.8333                                                  
    4  2.0833                                                  
    5  2.2833                                                  
    6  2.4500                                                  
    7  2.5929                                                  
    8  2.7179                                                  
    9  2.8290                                                  
   10  2.9290  
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM SHOWING THE USE OF A CAST Or get search suggestion and latest updates.

Rambert Fischer
Rambert Fischer author of PROGRAM SHOWING THE USE OF A CAST is from Frankfurt, Germany.
 
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!