Write an algorithm for a program that receives an integer as
input and outputs
the product of of its digits. E.g. 1234 = 24, 705 = 0
Answers were Sorted based on User's Feedback
Answer / krishna
#include<stdio.h>
#include<conio.h>
void main()
{
int n,n1.p=1;clrscr()printf("\n enter num");scanf("%d",&n);
while(n>0){ n1=n%10;p=p*n1;n=n/10;}printf("\n required answer is %d",p);
getch();
}
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / rahul
#include <stdio.h>
#include <math.h>
main()
{
int num,rem,qot,prod;
printf("enter the number ");
scanf("%d",&num);
prod=1;
while((num/10)>0)
{
rem=num%10;
prod=prod*rem;
num=(num-rem)/10;
}
printf("product is %d",prod);
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / abhisekh_banerjee
/* To get an number as input and add the digits of that number*/
#include<stdio.h>
#include<conio.h>
int main(void)
{
int a,b,c=1,i;
clrscr();
printf("Enter the number : ");
scanf("%d",&a);
for(i=0;a>0;i++)
{
b=a%10;
a=a/10;
c=c*b;
}
printf("\n%d",c);
return 0;
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / pavithra
jus use an array to store d i/p
nd multiply the array elements
| Is This Answer Correct ? | 0 Yes | 3 No |
Multiply an Integer Number by 2 Without Using Multiplication Operator
What is #include called?
main() { int x=5,y=10,z=0; x=x++ + y++; y=y++ + ++x; z=x++ + ++y; printf("%d%d%d\n",x,y,z); }
What is graph in c?
Is double link list a linear data structure? If Yes, Why?If No, Why?
What are the types of pointers?
what is c++ programming?
What is the purpose of the statement: strcat (S2, S1)?
Hi can anyone tell what is a start up code?
What are qualifiers?
write a c programs to do multiplication of two numbers with out using arithmatic operator ??????????
Explain what is the most efficient way to store flag values?