factorial series, C/C++ Programming

1)      Factorial (for this question just provide an answer for each part)

 1.1  Debug the following program to calculate N!

#include

using namespace std;

main()

{

            int N, factorial=1;

            cout << "Enter a positive integer"

            cin >> N;

            for(int i=N; i>=1; factorial *= --i);

            cout << N<<"!="<

return 0;

}

What was wrong?

1.2  Set N='A'. What is the result? Does it make sense? Modify the program to make sure that the entered value is numeric.

Also, modify the program such that it does not accept negative numbers and insists on getting a positive value for N. You can do so by using a while loop that keeps asking for a positive integer till a positive integer is entered.

1.3  Get your code to compute 1!,2!,5!, and 25!. Are you getting the correct answer for all of the entered values? If not, what went wrong? Would you be able to fix this by changing the variable type? Explain your answer.

Posted Date: 2/15/2013 7:33:31 AM | Location : United States







Related Discussions:- factorial series, Assignment Help, Ask Question on factorial series, Get Answer, Expert's Help, factorial series Discussions

Write discussion on factorial series
Your posts are moderated
Related Questions
Define Register Storage Class - computer programming? The Storage class register notify the compiler that the associated variables must be stored in high-speed memory register.

dispaly the last ant on rod

I want source code for class booking system by using C++ Programming...Urgent

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with '

Design and implement a library system that does the following: ? Takes details of a student/library users: first name, last name, other names, user ID number, and nationality. Th


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

2 flowcharts, pseudocode for each (at least 4 algorithms), and code for either a stack or a queuestion..

FIT 3042 System Tools and Programming Languages Semester 1 2013 Assignment 1 An SDL video player for a custom video format Worth: 20% of final mark. Must be completed individually

wap to cheak if a number is palindrom