Here in this article we will learn how to fix the no. of numbers in the double and floating point numbers (i.e 235.2356 after dot how many numbers there will be ) . For this we can use precision() . In this method we can write **cout.precision(x)** where value of x determine how many number there will me after dot (.) .

__Method 1:-__

#include <iostream>

#include <cstdio>

using namespace std;

int main() {

double a=123.4589;

double b=1.0e6;

double c=1256.32;

printf("%.2lf %.2lf %.2lf",a,b,c);

return 0;

}

__output:-__123.46 1000000.00 1256.32

__Method 2:-__

In this method we will use precision function which is predefine in iostream library file .

by using this we can simply set a limit a after dot in the floating and double numbers.

#include <iostream>

#include <cstdio>

using namespace std;

int main() {

double a=123.4589;

double b=1.0e6;

double c=1256.32;

cout.precision(2);

// In fixed notation

cout<<"In fixed notation"<<endl;

cout<<fixed<<a<<" "<<b<<" "<<c<<endl;

// In scientific notation

cout<<"In Scientific Notation"<<endl;

cout<<scientific<<a<<" "<<b<<" "<<c<<endl;

return 0;

}

__Output:-__In fixed notation

123.46 1000000.00 1256.32

In Scientific Notation

1.23e+02 1.00e+06 1.26e+03

__what is fixed and Scientific notation:-__

__What is fixed and scientific notation (Exponential notation)__

__Recommended Post:__

__Cracking the coding interview:-__

__Array and string:-__

__Tree and graph:-__

__Hackerearth Problems:-__

- Very Cool numbers | Hacker earth solution
- Vowel Recognition | Hackerearth practice problem solution
- Birthday party | Hacker earth solution
- Most frequent | hacker earth problem solution
- program to find symetric difference of two sets
- cost of balloons | Hacker earth problem solution
- Chacha o chacha | hacker earth problem solution
- jadu and dna | hacker earth solution
- Bricks game | hacker earth problem
- Anti-Palindrome strings | hacker earth solution
- connected components in the graph | hacker earth data structure
- odd one out || hacker earth problem solution
- Minimum addition | Hackerearth Practice problem
- The magical mountain | Hackerearth Practice problem
- The first overtake | Hackerearth Practice problem

__Hackerrank Problems:-__- Playing With Characters | Hackerrank practice problem solution
- Sum and Difference of Two Numbers | hackerrank practice problem solution
- Functions in C | hackerrank practice problem solution
- Pointers in C | hackerrank practice problem solution
- Conditional Statements in C | Hackerrank practice problem solution
- For Loop in C | hackerrank practice problem solution
- Sum of Digits of a Five Digit Number | hackerrank practice problem solution
- 1D Arrays in C | hackerrank practice problem solution
- Array Reversal | hackerrank practice problem solution
- Printing Tokens | hackerrank practice problem solution
- Digit Frequency | hackerrank practice problem solution
- Calculate the Nth term | hackerrank practice problem solution

__Data structure:-__

- Program to find cycle in the graph
- Implementation of singly link list
- Implementation of queue by using link list
- Algorithm of quick sort
- stack by using link list
- program to find preorder post order and inorder of the binary search tree
- Minimum weight of spanning tree
- Preorder, inorder and post order traversal of the tree

__Key points:-__

- How to set limit in the floating value in python
- What is boolean data type
- How to print any character without using format specifier

Must check this:-__ MCQs:-__

## 0 Comments