Write a program to increase the even digit and decrease the odd digit of a number.
#include<stdio.h>
int main(){
int n, rem, sum=0, t=0,r=0;
scanf("%d", &n);
while(n!=0){
rem =n%10;
if(rem%2 == 0)
{
rem++;
}
else{
rem--;
}
sum = sum*10 + rem;
n=n/10;
}
t=sum;
while(t!=0){
rem =t%10;
r = r*10 + rem;
t=t/10;
}
printf("%d", r);
return 0;
}
Comments
Post a Comment