write a program to accept 3 numbers and find the product of the last digits
Answers
Answer:
==========================================
C Program :
// cpp program to compute
// product of digits in the number.
#include<bits/stdc++.h>
using namespace std;
/* Function to get product of digits */
int getProduct(int n)
{
int product = 1;
while (n != 0)
{
product = product * (n % 10);
n = n / 10;
}
return product;
}
// Driver program
int main()
{
int n = 4513;
cout << (getProduct(n));
}
JAVA Program :
// Java program to compute
// product of digits in the number.
import java.io.*;
class GFG {
/* Function to get product of digits */
static int getProduct(int n)
{
int product = 1;
while (n != 0) {
product = product * (n % 10);
n = n / 10;
}
return product;
}
// Driver program
public static void main(String[] args)
{
int n = 4513;
System.out.println(getProduct(n));
}
}
PYTHON 3 Program :
# Python3 program to compute
# product of digits in the number.
# Function to get product of digits
def getProduct(n):
product = 1
while (n != 0):
product = product * (n % 10)
n = n // 10
return product
# Driver Code
n = 4513
print(getProduct(n))
C# Program :
// C# program to compute
// product of digits in the number.
using System;
class GFG
{
/* Function to get product of digits */
static int getProduct(int n)
{
int product = 1;
while (n != 0)
{
product = product * (n % 10);
n = n / 10;
}
return product;
}
// Driver program
public static void Main()
{
int n = 4513;
Console.WriteLine(getProduct(n));
}
}
PHP Program :
<?php
<?php
// PHP program to compute
// $product of digits in the number.
/* Function to get $product of digits */
function getProduct($n)
{
$product = 1;
while ($n != 0)
{
$product = $product * ( $n % 10);
$n = intdiv($n , 10);
}
return $product;
}
// Driver code
$n = 4513;
echo getProduct($n);
?>