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
One of the best known methods for external sorting on tapes is the polyphase sort. Principle: The basic strategy of this sort is to distribute ordered initial runs of predetermi

B-trees are special m-ary balanced trees utilized in databases since their structure allows records to be added, deleted & retrieved with guaranteed worst case performance. A B-

Here,  m represents the unordered array of elements n  represents number of elements in the array and el  represents the value to be searched in the list Sep 1: [Initialize]

how to design a cache simulator with 4-way set associative cache

For a queue a physical analogy is a line at booking counter. At booking counter, customers go to the rear (end) of the line & customers are attended to several services from the fr

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))

Define Minimum Spanning Tree A minimum spanning tree of a weighted linked graph is its spanning tree of the smallest weight, where the weight of a tree is explained as the sum

What are the conditions under which sequential search of a list is preferred over binary search? Sequential Search is a preferred over binary search when the list is unordered

This algorithm inputs number of hours of sunshine recorded every day for a week (7 days). Output is the highest value for hours of sunshine and average (mean) value for numbers of

The Space - Time Trade Off The best algorithm to solve a given problem is one that needs less space in memory and takes less time to complete its implementation. But in practic