Find error for curious number, Data Structure & Algorithms

#include
#include
int sumFact(int numb);
int calculateFactorial(int digit);

main()
{
int numb, sumfact;
do{
printf ("Enter a number 1 to 9999\n");
scanf("%d", numb);
printf("\n");
}
while (!(numb >= 1 && numb <=9999));
sumfact = sumFact(numb);
if (numb == sumfact)
{
printf("\nThe Number %d you entered is curious number", numb);
}
else
{
printf("\n not a curious number", numb);
}
}
int sumFact (int numb)
{
int rightdigit, sumfact = 0;
while (numb != 0)
{
rightdigit = numb%10;
numb = numb /10;
sumfact = sumfact + calculateFactorial (rightdigit);
}
return sumfact;
}
int calculateFactorial (int digit)
{
int factval;
if ((digit == 0 ) && (digit == 1))
{
return (1);
}
else
{
factval = digit*calculateFactorial (digit-1);
return factval;
}
}
Posted Date: 3/16/2013 4:55:04 PM | Location : United Arab Emirates







Related Discussions:- Find error for curious number, Assignment Help, Ask Question on Find error for curious number, Get Answer, Expert's Help, Find error for curious number Discussions

Write discussion on Find error for curious number
Your posts are moderated
Related Questions
The advantage of list over Arrays is flexibility. Over flood is not a problem until the computer memory is bushed. When the individual record are quite large, it may be difficult t

What do we mean by algorithm? What are the characteristics of a good and relevant algorithm? An algorithm is "a step-by-step procedure for finishing some task'' An algorithm c

Q. Consider the specification written below of a graph G V(G ) = {1,2,3,4} E(G ) = {(1,2), (1,3), (3,3), (3,4), (4,1)} (i)        Draw the undirected graph. (

This notation gives an upper bound for a function to within a constant factor. Given Figure illustrates the plot of f(n) = O(g(n)) depend on big O notation. We write f(n) = O(g(n))

W h at are the different ways by which we can represent graph?  Represent the graph drawn below using those ways.     T he d iff e r e nt w a y s by

The searching method are applicable to a number of places in current's world, may it be Internet, search engines, text pattern matching, on line enquiry, finding a record from data

Develop a program that accepts the car registration( hint: LEA 43242010)

explanation of doubly linklist

Simulation is the process of making an abstract model of a real world situation in order to be aware of the effect of modifications and alterations and the effect of introducing nu

Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.