Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Why doesnt that code work?

0 Answers  


What is #pragma statements?

0 Answers  


post new interiew question and aptitude test papers

1 Answers  


What is function definition in c?

0 Answers  


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

0 Answers  






What are the general description for loop statement and available loop types in c?

0 Answers  


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

0 Answers  


What is the best way to comment out a section of code that contains comments?

0 Answers  


Can we initialize extern variable in c?

0 Answers  


Why use int main instead of void main?

0 Answers  


Can you please explain the difference between syntax vs logical error?

0 Answers  


main() {int a=200*200/100; printf("%d",a); }

14 Answers   TCS,






Categories