Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,970 questions

51,912 answers

573 users

How to use floating point types in C

1 Answer

0 votes
#include <stdio.h>

int main(void) 
{
    float f = 0.3f;  
    double d = 3.14;  
    long double ldbl = 0.897543l; 

    double a = 3.; 
    double b = .3; 
    
    double c = 3.7e3; 
    
    printf("f = %.1f\n", f);
    printf("d = %.2f\n", d);
    
    printf("ldbl = %le\n", ldbl);
    
    printf("a = %.1f\n", a);
    printf("b = %.1f\n", b);
    
    printf("c = %.1f\n", c);
    
    return 0;
}
    
/*
run:
 
f = 0.3
d = 3.14
ldbl = 1.133015e-317
a = 3.0
b = 0.3
c = 3700.0

*/

 



answered Aug 24, 2017 by avibootz

Related questions

1 answer 117 views
1 answer 97 views
1 answer 139 views
1 answer 101 views
1 answer 142 views
1 answer 193 views
...