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 |
Explain the properties of union. What is the size of a union variable
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?
Explain how can I read and write comma-delimited text?
Which control loop is recommended if you have to execute set of statements for fixed number of times?
What are the preprocessor categories?
wat is the difference between array and pointer?
how to find sum of digits in C?
please give me some tips for the selection in TCS.
Explain the bubble sort algorithm.
Who developed c language?
What does != Mean in c?