Computer Science, asked by shreeparnagupta3, 5 hours ago

in c++ wap to input a number and print the product of it's digits using while loop programs​

Answers

Answered by BrainlyProgrammer
4

Answer:

#include <iostream>

using namespace std;

int main() {

int n;

cout<<"Enter a number";

cin>> n;

int p=1;

while(n!=0){

p*=n%10;

n/=10;

}

cout<<endl<<"Product:-"<<p;

return 0;

}

Logic:-

  • Accept a number
  • Run a while loop
  • Extract the digits
  • Find the product
  • Finally, print the product after while loop ends
Similar questions