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
how to implement multiple stack using single dimension array in c

#questWrite an algorithm for multiplication of two sparse matrices using Linked Lists.ion..

P os t - o r d e r T r av er sal :  This can be done by both iteratively and recursively. The iterative solution would require a modification or alteration of the in-

Define Dynamic Programming  Dynamic  programming  is  a  method  for  solving  problems  with  overlapping  problems.  Typically, these sub problems arise from a recurrence rel


Program: Creation of a Circular linked list ALGORITHM (Insertion of an element into a Circular Linked List) Step 1        Begin Step 2      if the list is empty or new

Q. Explain what do we understand by Binary Search Tree (BST)? Make a BST for the following given sequence of the numbers. 45, 32, 90, 21, 78, 65, 87, 132, 90, 96, 41, 74, 92

Program: Program segment for insertion of an element into the queue add(int value) { struct queue *new; new = (struct queue*)malloc(sizeof(queue)); new->value = val

differentiate between indexing and hashing in file organization

Assume a complete binary tree T with n nodes where each node has an item (value). Label the nodes of the complete binary tree T from top to bottom & from left to right 0, 1, ..., n