Function Program19

//with return value, without argument .. reverse number


#include<stdio.h>

#include<conio.h>


int rev();


void main()

{

int revno;

clrscr();


revno = rev();


printf("\nReverse number = %d", revno);


getch();

}


int rev()

{

int no, rem, revno=0;


printf("\nEnter number: ");

scanf("%d", &no);


while(no > 0)

{

rem = no % 10;

revno = revno * 10 + rem;

no = no / 10;

}


return revno;

}

No comments:

Post a Comment