main()
{
long num,a,b,c,d,e,new;
clrscr();
printf("Enter a five digit number\n");
scanf("%ld",&num);
a=((num%10)+1)%10;
e=num/10;
b=((e%10)+1)%10;
e=e/10;
c=((e%10)+1)%10;
e=e/10;
d=((e%10)+1)%10;
e=((e/10)+1)%10;
new=10000*e+1000*d+100*c+10*b+1*a;
printf("Result is %ld",num,new);
}
output:-
#include
ReplyDeleteint main()
{
int a,b=0,c=0,d=0,e=0;
printf("Enter te no: ");
scanf("%d",&a);
b=a;
while(b>0)
{
b=b/10;
++c;
}
printf("No. of digits %d ",c);
while(c!=0)
{
d=d*10+1;
c--;
}
e=a+d;
printf(" %d",e);
getch();
}
Thank you 😊
Deletethis code gives wrong output if the number contains "9" in it.
Deletethis code gives the same number as the output.
ReplyDelete