Answers for "print onlly 2 integer in float in c++"

C++
2

how print fload wiht 2 decimal in c++

#include <iostream>
#include <cstdio>
using namespace std;

int main() 
{
    // This code helps you to print a number with desired decimal
    double Number=10.3454;
    printf("%.3lf",Number);

    return 0;
}
Posted by: Guest on June-07-2020
0

print float number with only four places after the decimal point in c++

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
  value = 3.15647;
  std::cout << std::fixed << std::setprecision(2);
  std::cout<<value<<std::endl;
	return 0;
}
Posted by: Guest on March-10-2022

Browse Popular Code Answers by Language