Friday, December 13, 2019

Write a source code for C++ and Java program to enter three digit number and print reverse form ?




Source code for C++ program to enter three digit number and print reverse form.


#include<iostream.h>
#include<conio.h>
void main()
{
int num,temp1,temp2;
clrscr();
cout<<"  Enter any three digit number:" ;
cin>>num;
temp1=(num%10);
num=(num/10);
temp2=(num%10);
num=(num/10);
cout<<"Entered number reverse :"<<temp1<<temp2<<num;
getch();
}


Source code for  Java program to enter three digit number and print reverse form.

import java.util.Scanner;
class reverse
{
public static void main(String []args)
{
int num, temp1,temp2;
Scanner sc=new Scanner(System.in);
System.out.println("  Enter any three  digit number: "   );
num=sc.nextInt( );
temp1=(num%10);
num=(num/10);
temp2=(num%10);
num=(num/10);
System.out.println("Entered number reverse :" +temp1+temp2+num);
}
}


No comments:

Post a Comment