Thursday, July 30, 2009

C program to display the reverse of a number...?

Write a C program to display the reverse of a number entered by the user

C program to display the reverse of a number...?
#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int x,y,z;


scanf("%d",%26amp;x);


if(x%26lt;0) x=x*(-1);


while(x%26gt;10)


{


y=x/10;


z=x%10;


x=y;


printf("%d",z);


}


printf("%d",x);


}
Reply:actually this is in C++





int n=12345,m=0;


cout%26lt;%26lt;"Orginal No:"%26lt;%26lt;n;


while(n%26gt;0)


{


m *= 10;


m += n%10;


n /= 10;


}





cout%26lt;%26lt;"\nRevesed No:"%26lt;%26lt;m;
Reply:#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int x,y,z;


scanf("%d",%26amp;x);


if(x%26gt;0)


{


y=x/10;


z=x%10;


x=y;


printf("%d",z);


}


printf("%d",x);


}


No comments:

Post a Comment