Explore
ProGrad Programs
Placement Prep
TCS Codevita
Live Placement Training
Webinars
About Us

Edit
Reply




Edit

Program to replace all 0's with 1 in a given integer | Face Prep

Published on 10 Mar 2020

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


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.


Program to replace all 0's with 1 in a given integer is given below.


C
C++
Java
Python 3

Output
Enter the number : 80150
The number after replacement : 81151


Time complexity:O(n)


Recommended Programs






If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in