How to print positive numbers with plus sign in C++

1 Answer

0 votes
#include <iostream>
#include <iomanip> 

int main() {
    int x = 12, y = -8;

    std::cout << std::showpos << x << "\n";
    
    std::cout << std::showpos << y << "\n";
}




/*

run:

+12
-8

*/

 



answered May 4, 2021 by avibootz
...