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 |
What is the scope of global variable in c?
how can u print a message without using any library function in c
write a program to print infinte number
What is stack in c?
What is an auto variable in c?
code for replace tabs with equivalent number of blanks
Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 5 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.
can we have joblib in a proc ?
Is javascript based on c?
Why doesn't the code "a[i] = i++;" work?
What is abstract data structure in c?
Can we declare function inside main?