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 ceil in C

2 Answers

0 votes
#include <stdio.h>
#include <math.h>

int main(void) {
    float f1 = 1.1f, f2 = 1.5f, f3 = 1.6f, f4 = 1.9f, f5 = 0.01f;

    printf("%.1f\n", ceil(f1));
    printf("%.1f\n", ceil(f2));
    printf("%.1f\n", ceil(f3));
    printf("%.1f\n", ceil(f4));
    printf("%.1f\n", ceil(f5));

    return 0;
}



/*
run:

2.0
2.0
2.0
2.0
1.0

*/

 



answered Jun 10, 2022 by avibootz
0 votes
#include <stdio.h>
#include <math.h>

int main(void) {
    float f1 = -1.1f, f2 = -1.5f, f3 = -1.6f, f4 = -1.9f, f5 = -0.01f;

    printf("%.1f\n", ceil(f1));
    printf("%.1f\n", ceil(f2));
    printf("%.1f\n", ceil(f3));
    printf("%.1f\n", ceil(f4));
    printf("%.1f\n", ceil(f5));

    return 0;
}



/*
run:

-1.0
-1.0
-1.0
-1.0
-0.0

*/

 



answered Jun 10, 2022 by avibootz

Related questions

2 answers 111 views
111 views asked Jun 10, 2022 by avibootz
1 answer 106 views
106 views asked Nov 29, 2022 by avibootz
1 answer 109 views
109 views asked Oct 7, 2022 by avibootz
1 answer 154 views
154 views asked Aug 4, 2020 by avibootz
2 answers 178 views
...