23.12.19

Reverse program in c

#include<stdio.h>
#include<conio.h>
main()
{
int n,r,sum=0;
clrscr();
printf("enter the number to reverse the number");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
printf("the reverse number is"+sum);
}


OUTPUT:

enter the number to reverse the number 345
the reverse number is 543

No comments:

Post a Comment

JAVA program pattern 2

import java.util.Scanner; public class pattern3 { public static void main(String args[]) { int i,j; Scanner sc=new Scanner(System.in); Syste...