C

One Digit Replace By 0

84
0

The program must accept an integer N as the input. The program must replace all the occurrences of the unit digit of N by 0 in the integer N. Finally, the program must print the modified value of N as the output.

Boundary Condition(s):

1 <= N <= 10^8

Input Format:

The first line contains the value of N.

Output Format:

The first line contains the modified value of N.

Example Input/Output 1:

Input
1021
Ouput
20
Explanation:
The unit digit of 1021 is 1.
So after replacing all the occurrence of 1 by 0, the integer becomes 0020.
Hence the output is 20

Example Input/Output 2:

Input
202202
Ouput
0

#include<stdio.h> 
#include<stdlib.h>

int main()

{

	int n; 
	scanf("%d",&n); 
	int k=0; 
	int a[10000000]; 
	int m=n%10;
	while(n>0)
	{
		if(n%10==m)
			a[k]=n%10;
		else
			a[k]=0;
		k++;
		n/=10;
	}
	k--;
	while(a[k]==0 && k>0)
	{
		k--;
	} 
	for(;k>=0;k--) 
	{
		printf("%d",a[k]);
	}
}
Hephzibai
WRITTEN BY

Hephzibai

Hephzibai is a driven third-year student at St. Joseph's Institute of Technology, specializing in Computer Science and Engineering. With a keen interest in data science and also in fullstack.
One of my greatest strengths lies in my programming skills, which I've honed through countless hours of practice and participation in coding challenges. Platforms like Skillrack, HackerRank, and others have been my playgrounds, where I've tackled a wide range of problems with creativity and determination.

Leave a Reply

Your email address will not be published. Required fields are marked *