# Loops

## Program to Reverse Number in Java

Here you will learn how to reverse number in java with a program example. For example given number is 1478 then its reverse will be 8741. Program to Reverse Number in Java package com; import java.util.Scanner; class Reverse { public static void main(String…s) { int n,rev=0,i; Scanner sc = new Scanner(System.in); System.out.println(“Enter any number: “); …

## Program for Factorial in Java

Here you will get program for factorial in java. We can find factorial of any number by multiplying it with all the numbers below it. For example, factorial of 4 is 4*3*2*1 = 24. Program for Factorial in Java package com; import java.util.Scanner; class Factorial { public static void main(String…s) { int n,fac=1,i; Scanner sc …

## Number Palindrome in Java

Here you will learn about number palindrome in java. A number is called palindrome if it is equal to its reverse. For example 1221 is a palindrome while 1234 is not palindrome. Below I have shared the java program to check given number is palindrome or not. Also Read: String Palindrome in Java   Program …

## Java Program to Display Multiplication Table of Any Number

Here you will get java program to find multiplication table of given number. class Table { public static void main(String…s) { int n,i; n=Integer.parseInt(s[0]); for(i=1;i<=10;++i) System.out.println(n+” * “+i+” = “+(n*i)); } }   Output

## Java Program to Find Sum of Digits of a Number

Here you will get java program to find sum of digits of a number. For example if given digit is 125 then its sum will be 8. class sum { public static void main(String…s) { int n,i,sum=0; n=Integer.parseInt(s[0]); while(n!=0) { i=n%10; sum+=i; n/=10; } System.out.println(sum); } }   Output

## Program for Prime Number in Java

Here you will get program for prime number in java. A number is prime if it is divisible by 1 or itself. For example 2, 3, 5, etc are prime numbers while 4, 6, 8, etc are not prime. Program for Prime Number in Java class prime { public static void main(String…s) { int n,i; …

## C Program to Find LCM and HCF of Two Numbers

Here you will get C program to find lcm and hcf of two given numbers. #include<stdio.h> int main() { int a,b,hcf,lcm,max,min,r; printf(“Enter two numbers:”); scanf(“%d%d”,&a,&b); if(a>b) { max=a; min=b; } else if(b>a) { max=b; min=a; } if(a==b) hcf=a; else { do { r=max%min; max=min; min=r; }while(r!=0); hcf=max; } lcm=(a*b)/hcf; printf(“\nLCM=%d\nHCF=%d”,lcm,hcf); return 0; }   Output …

## Convert Binary to Decimal in C

Here you will get program to convert binary to decimal in C. We can obtain a decimal number by multiplying each digit of binary number with power of 2 and adding each multiplication result. The power starts from 0 and goes to n-1 where n is the total number of digits in binary number. Below …