Computer Science, asked by swastika015, 6 hours ago

write a program to find the first and last digit of a three digit number?

In java.

Answers

Answered by aljiyashibu
2

Answer:

number using loop:

#include <stdio.h>

int main()

{

int n, sum=0, firstDigit, lastDigit;

printf("Enter number = ");

scanf("%d", &n);

// Find last digit of a number.

lastDigit = n % 10;

Answered by ItzMeSam35
2

import java.util.Scanner;

public class Three_Digit

{

public static void main (String args [])

{

Scanner sc=new Scanner(System.in);

System.out.print("Please enter a three digit value : ");

int value = sc.nextInt();

int first_digit = value / 100;

int last_digit = value % 10;

System.out.println("First Digit : "+first_digit);

System.out.println("Last Digit : "+last_digit);

sc.close();

}

}

Similar questions