Computer Science, asked by deepadev81, 9 months ago


Design a function long product(long num)- to find and return the product of first and last digit of number
stored in the parameter num.​

Answers

Answered by vkjaiswal2144
4

Answer:

long product(long num)

{

int firstdigit,lastdigit;

lastdigit=num%10;

while(num>0)

{

firstdigit=num%10;

num=num/10;

}

return firstdigit*lastdigit;

}

Explanation:

There is a function In which a number has been passed. then num%10 will give the last digit of number and by using the while loop we can find the firstdigit as last time when while loop will run it will give the first digit of number. then it will become 0 by using num=num/10.

Similar questions