Thread: DD to DMS

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    338

    Thumbs up

    from DD to DMS
    Code:
    #include <stdio.h>
    
    
    double DD = 0.0, seconds, remain ;
    int degrees = 0, minutes = 0;
    
    
    int main() {        
            
        DD = 13.5423; 
        
        degrees = (int)DD; 
         remain = ((DD-degrees)*60);
        minutes = (int)(remain);
        seconds = ((remain-minutes)*60);
    
    
        printf( "DD:\t %f \n", DD );
        printf( "DMS:\t %i° %i' %.2f\" \n", degrees, minutes, seconds);
    
    
        return 0;
    }
    Last edited by Structure; 05-10-2021 at 10:08 AM.
    "without goto we would be wtf'd"

Popular pages Recent additions subscribe to a feed

Tags for this Thread