iomanip


1. Formatting Integer Output

#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  int num = 12345;
  cout << setw(10) << num; // Output:  12345
  return 0;
}

2. Left-Justifying String Output

#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  string str = "Hello";
  cout << setw(10) << left << str; // Output: Hello
  return 0;
}

3. Right-Justifying String Output

4. Centering String Output

5. Setting Field Width

6. Truncating Output

7. Inserting Leading Zeros

8. Inserting Leading Spaces

9. Formatting Floating-Point Numbers

10. Suppressing Scientific Notation

11. Formatting Boolean Values

12. Formatting Hexadecimal Values

13. Formatting Octal Values

14. Formatting Money

15. Formatting Dates

16. Formatting Characters

17. Formatting Pointers

18. Formatting User-Defined Types (struct)

19. Formatting User-Defined Types (class)

20. Avoiding Left-Padding

21. Suppressing Leading Zeros for Float

22. Using showpoint for Float

23. Aligning Characters

24. Using Copy Delimiter

25. Suppressing Trailing Zeros

26. Using setbase

27. Using setfill

28. Using left

29. Using noshowpos

30. Using right

31. Using scientific

32. Using setprecision

33. Using showpoint

34. Using uppercase

35. Using ws

36. Using oct

37. Using hex

38. Using fixed

39. Using boolalpha

40. Using flush

41. Using dec

42. Using copyfmt

43. Using setbase

44. Using setw

45. Using internal

46. Using showpos

47. Using setfill

48. Using setprecision

49. Using uppercase

50. Using ws