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 Linked list is a chain of structures wherein each structure contains data in addition to pointer, which stores the address (link) of the next logical structure in the list.

Suppose you are given the results of 5 games of rock-paper-scissors. The results are given to you on separate pieces of paper; each piece says either 'A' if the first person won, o

The pre-order and post order traversal of a Binary Tree generates the same output. The tree can have maximum One node

If a node having two children is deleted from a binary tree, it is replaced by?? Inorder successor

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

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

Programming for hash table?

Q. Describe the term array.  How do we represent two-dimensional arrays in memory?  Explain how we calculate the address of an element in a two dimensional array.

(1)  (i) Add the special form let to the metacircular interpreter Hint: remember let is just syntactic sugar for a lambda expression and so a rewrite to the lambda form is all t

Q. Write down an algorithm to convert an infix expression into the postfix expression.     Ans. Algo rithm to convert infix expression to post fix expression is given as