Wednesday, July 14, 2021

9. Write a program to add 8 to the number 2345 and then divide it by 3. Now, the modulus of the quotient is taken with 5 and then multiply the resultant value by 5. Display the final result.

 public class Main {

      public static void main(String[] args) {

          int a = 2345;

          int b = a + 8;

          int c = b / 3;

          int d = c % 5;

          int e = d * 5;

          System.out.println(e);

     }

}


NOTE:

  • The output of this program will come 20.
  • Used int as there is no decimal in the value.
  • Didn't use Scanner as there was no need to take input from the user.

No comments:

Post a Comment