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

Bit swapping

2 Answers  


write a program to display reverse of a number using for loop?

14 Answers  


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

0 Answers  


What is memmove?

1 Answers   Oracle,


main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m); }

7 Answers   HCL,






What is function and its example?

0 Answers  


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

0 Answers  


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

0 Answers   Oracle,


What is the difference between a string and an array?

0 Answers  


My teacher ask to make a program that can: Insert record in front Insert record at the end Insert in between Search node record Delete record in front Delete record at the end Delete record in between Using Data structure Linked List type. But I'm really confused about the codes and I can't go through. Please help Thanks in advance. Also here is my unfinished code if someone can make changes it will be more good.

1 Answers  


main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }the o/p is morning and e...how someone explain

1 Answers  


How do I copy files?

0 Answers  


Categories