Write a java program to find first digit,last digit and sum of given number ?

preview_player
Показать описание
1) How to read a matrix from console in java?

2) How to remove duplicates from string in java?

3) Write a java program to duplicate characters with number of occurences in java?

4) Write a java program to implement bubble sort part 1?

5) Write a java program to check string is palindrome or not?

6) Write a java program to print floyds triangle?

7) Write a java program to print floyds triangle?





8) How to count number of vowels in a string in java?

9) How to find largest and smallest values in an array in java?

10) Write java program to find duplicate elements in array in java?

11) write a java program to check the input number is prime or not in java?

12) Write a java program to print pyramid pattern of numbers?

13) Write a java program to find missing number in array in java?

14)Write a java program to print numbers in java up to 10 with out using loops?

15) How to sort elements in array in asc and desc order in java?



16) Write a java program to find factorial of a number in java?

17) write a java program to find second largest element in the array in the java?

18) Write a java program to check two Strings are anagrams or not by sorting and comparing strings?

19) Write java program to print Characters count in each word in String ?

20) Write a java program to find reverse of a string in java?

21) Write a java program to add elements in an array in java?

22) Write a java program to find largest of three numbers?



23) Write a java program to print multiplication table?

24) Write a java program to print star pattern?

25) Write a java program to find factors of number from 1 to 100

26) Write a java program to print fibonacci series using loops?

27) Write a java program to print Ascii values of a Character ?

28) write a java program to implement bubble sort - Part 2?

29) Write a java program to print fibonacci series ?

30) Write a java program to sort characters in String in java?

31) How to sort hashmap keys in java?

32) Write a java program to check two strings are anagrams or not?

33) Write a java program to find factorial for large number?

34) Write a java program to find even and odd number?

35) How to Swap two numbers without using third variable in java?(Addition and subtraction operation)

36) Write a java program to convert Fahrenheit to celsius?

37) Write a java program to find reverse of a number in java?

38) Write a java program to print alphabets?

39) Write a java program to check given input character is alphabet or not ?

40) How to reverse the order of elements in arraylist in java?

41) How to swap elements in list in java?

42) Write a java program to find sum of 10 numbers in java?

43) How to swap two numbers in java?

44) How to swap two numbers in java with out using temp variable?

45) Write a java program to check whether array contains duplicates?

46) How to calculate area of Rectangle in java?

47) Write a java program to find factorial of a number recursion?

48) How to calculate area and circumference of a circle in java?

51) write a java program to add,multiply and average of numbers?

52) How to delete element from array in java?

Рекомендации по теме
Комментарии
Автор

Thank you sir for such great explanation

sheenvarghese
Автор

convet to string reverse the number and then % by 10 you get the first digit(if there is no restriction to use java inbuilt methods)

rohitmore
Автор

If the input is 001, its returning 1 as first digit and 1 as last digit due to which the sum of first and last digit is equals 2
that is practically totally wrong, so please suggest us what to do in order to solve this problem.

rohanraj
Автор

Thanks Sir, Wonderful job, is it possible for you to paste the coding in comment

itspossible
Автор

int firstDigit = 0, lastDigit = num % 10;
while (num > 0) {
int digit = num % 10;
num = num / 10;
firstDigit = digit;
sum = sum + digit;
}

RakibHasan-
Автор

for OOPS concept it could be much easier .. like
import java.util.*;
public class SumOfFirstLast {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
int num = sc.nextInt();
int S=0;
int[] digits = -> c-'0').toArray();
for(int i=0;i<=digits.length;i++) {

}
System.out.println(S);
}

}

swarnalibhattacharjee
Автор

Sir mujhe first price last digit number how calcutta at hindi version

rajanunia
Автор

Sir if the num ==100
Then we use
Firstdigit=num
While(Firstdigit>=10)
{Firstdigit=Firstdigit/10}
return Firstdigit
Thn sir our output will be 10
So sir i think we use while(Firstdigit>=9)

gopaljaiswal
Автор

sir in this way can i do?
import java.util.*;
public class Code1 {

public static void main(String[] args) {


Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
int LastDigit=num%10;
int FirstDigit=num;
int s=0;
int r;
//int p;
while(FirstDigit>=10)
{


}
System.out.println("the last digit is->"+LastDigit);
System.out.println("the ist digit->"+FirstDigit);
int sum=FirstDigit+LastDigit;
if(sum>=10)
{






}
System.out.println("the sum is->"+s);
}
else
{
is->"+ sum);
}



}


}

debasispadhi