Programming Examples
Java program to initialize three int variables a, b and c with 234, 456 and 712 and store the sum of the last digits of the variables
Write a program to initialize three int variables a, b and c with 234, 456 and 712 and store the sum of the last digits of the variables into d and display it.
Solution
class SumLastDigit
{
public static void main(String arr[])
{
int a=234,b=456,c=712,d;
d=a%10+b%10+c%10;
System.out.println(“Sum=”+d);
}
}
Output