Computer Science, asked by pitbullkrish, 3 months ago

Write a java program to calculate the product of the first and the third last digit of a 5 digit number. ​
Sample Input: 52346
Output expected: 5*3 =15

Answers

Answered by kamalrajatjoshi94
1

Answer:

Program:-

import java.util.*;

public class Product

{

public static void main(String args[ ])

{

Scanner in=new Scanner(System.in);

int n,a=0,p=1,c=0;

System.out.println("Enter the five digit number");

num=in.nextInt();

while(n>0)

{

a=n%10;

c++;

if(c==5&&c==3)

p=p*n;

n=n/10;

}

System.out.println("The product of first and third last digit="+p);

}

}

Answered by svaishnavi2806
0

Answer:

Explanation:

import java.util.Scanner;

public class Main{

   public static void main(String args[]){

       int num,n,m,o,o1,o2,p;

       Scanner obj=new Scanner(System.in);

       System.out.println("Enter a five digit number: ");

       num=obj.nextInt();

       n=num/10;

       m=n/10;

       o=m%10;

       o1=m/10;

       o2=o1/10;

       p=o*o2;

       System.out.println("The product of first and  third last digit is ",+p);

       

       

   }

}

Similar questions