if 5 digit number is input through kryboard , then wap to print a new number by adding one to each digit . for example if the input is 12391 then output should be 23402.(loop)



 



#include<stdio.h>
#include<conio.h>
 main()
{
   int n,r,add=0,rev=0;


   printf("Please enter any  number ");
   scanf("%d",&n);

     while(n>0)
     {
       r=n%10;
       n=n/10;
       rev=rev*10+r;
     }

     while(rev>0)
     {
       r=rev%10;
       rev=rev/10;
       r=r+1;
r=r%10;
       add=add*10+r;
     }

    printf("%d",add);


}

output :
Please enter any number 345678 456789

Comments

Popular Post

Define a class to represent a Bank Account. Include the following members: Data Members: i. Name of the depositor ii. Account number iii. Type of account iv. Balance amount in the account Member Functions: 1. To Input initial values 2. To deposit an amount 3. To withdraw an amount after checking the balance 4. To display name and balance Also write constructor for this class that takes four arguments. It should also handle type of account as savings by default