Computer Science, asked by ranolipreeti19, 1 month ago

Write a program to check whether the last digit of a number( entered by user ) is divisible by 3 or not.​

Answers

Answered by debarunbanerjee1205
1

Answer:

import java.util.*;

class number{

public static void main(String args[]){

Scanner sc=new Scanner(System.in);

System.out.println("Enter any number");

int a=sc.nextInt();

if(a/3==0){

System.out.println("The given number is divisible by 3");

}

else{

System.out.println("The given number is not divisible by 3");

  }

}

}

hope it helps.

pls mark me as the brainliest

Answered by ashutoshmishra3065
1

Answer:

Explanation:

Phyton:

Python is a popular computer programming language used to create software and websites, automate processes, and analyze data. Since Python is a general-purpose language, it may be used to develop a wide range of programs and isn't tailored for any particular issues.

Guido van Rossum created Python, an interpreted, object-oriented, high-level programming language with dynamic semantics. It was first made available in 1991. The name "Python" is a tribute to the British comedy group Monty Python and is meant to be both simple and entertaining.

Python is today among the most well-known and frequently used programming languages in the world, despite having its origins as a side project bearing the moniker Monty Python. Python is used for data analytics, machine learning, and even design in addition to web and software development.

Write a program to check whether the last digit of a number( entered by user ) is divisible by 3 or not.​

Step 1:

This software determines if the user-entered number's last digit is divisible by three or not.

In the following step, locate the program.

Step 2:

Source code:

number=int(input("Enter the number : "))

last_digit = number%10

if(last_digit%3==0):

print("Last digit of given number is {} and  is divisible by 3".format(last_digit))

else:

print("Last digit of given number is {} and  is not divisible by 3''.format(last_digit))

Step 3:

Enter the number : 33

Last digit of the given number is 3 and is divisible by 3.

Enter the number : 45

Last digit of the given number is 5 and is not divisible by 5.

#SPJ2

Similar questions