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

Write the definition for a class called complex that has floating point data members for storing real and imaginary parts. The class has the following member functions: void set(float, float) to set the specified value in object void disp() to display complex number object complex sum(complex) to sum two complex numbers & return complex number 1. Write the definitions for each of the above member functions. 2. Write main function to create three complex number objects. Set the value in two objects and call sum() to calculate sum and assign it in third object. Display all complex numbers.