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



Write an algorithm for a program that receives an integer as input and outputs the product of of i..

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

Write an algorithm for a program that receives an integer as input and outputs the product of of i..

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

Write an algorithm for a program that receives an integer as input and outputs the product of of i..

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

Write an algorithm for a program that receives an integer as input and outputs the product of of i..

Answer / pavithra

jus use an array to store d i/p
nd multiply the array elements

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More C Interview Questions

What is the scope of global variable in c?

0 Answers  


how can u print a message without using any library function in c

1 Answers   NIIT,


write a program to print infinte number

4 Answers  


What is stack in c?

0 Answers  


What is an auto variable in c?

0 Answers  






code for replace tabs with equivalent number of blanks

0 Answers   Bosch,


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.

1 Answers  


can we have joblib in a proc ?

0 Answers  


Is javascript based on c?

0 Answers  


Why doesn't the code "a[i] = i++;" work?

4 Answers  


What is abstract data structure in c?

0 Answers  


Can we declare function inside main?

0 Answers  


Categories