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 <iostream>
#include <cmath>
 
int main(void) {
    float f1 = 1.1f, f2 = 1.5f, f3 = 1.6f, f4 = 1.9f, f5 = 0.01f;
 
    std::cout << ceil(f1) << "\n";
    std::cout << ceil(f2) << "\n";
    std::cout << ceil(f3) << "\n";
    std::cout << ceil(f4) << "\n";
    std::cout << ceil(f5) << "\n";

    return 0;
}
 
 
 
/*
run:
 
2
2
2
2
1
 
*/

 



answered Jun 10, 2022 by avibootz
0 votes
#include <iostream>
#include <cmath>
 
int main(void) {
    float f1 = -1.1f, f2 = -1.5f, f3 = -1.6f, f4 = -1.9f, f5 = -0.01f;
 
    std::cout << ceil(f1) << "\n";
    std::cout << ceil(f2) << "\n";
    std::cout << ceil(f3) << "\n";
    std::cout << ceil(f4) << "\n";
    std::cout << ceil(f5) << "\n";

    return 0;
}
 
 
 
/*
run:
 
-1
-1
-1
-1
-0

*/

 



answered Jun 10, 2022 by avibootz

Related questions

2 answers 114 views
114 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
...