Program to replace all 0’s with 1 in a given integer | Faceprep

Program to replace all 0’s with 1 in a given integer | Faceprep



program to replace all 0s with 1s in a given integer


The program to replace all 0’s with 1 in a given integer is discussed here. Given an integer as an input, all the 0’s in the number has to be replaced with 1.

For example, consider the following number

Input: 102405

Output: 112415

Input: 56004

Output: 56114


algorithmClick here to learn more about FACE Prep PRO


Algorithm to replace all 0’s with 1 in a given integer

  • Input the integer from the user.
  • Traverse the integer digit by digit.
  • If a ‘0’ is encountered, replace it by ‘1’.
  • Print the integer.

The program to replace all 0’s with 1 in a given integer is given below.

@@coding::1@@

Time complexity:O(n)


algorithm to replace all 0s with 1Click here to learn more about FACE Prep PRO


Recommended Programs


program to replace all 0s with 1s in a given integer

c