factorial series, C/C++ Programming

Assignment Help:

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.


Related Discussions:- factorial series

C pgms, find area under the curve y=f(x) between x=a &y=b integrate y=f(x)

find area under the curve y=f(x) between x=a &y=b integrate y=f(x)

Advantages to the use of functions, Question: (a) What is a function? A...

Question: (a) What is a function? Are functions needed when writing a C program? (b) State one of the advantages to the use of functions. (c) What do you meant by underst

How the compiler arranges the several sections , Q: How the compiler arrang...

Q: How the compiler arranges the several sections in the executable image? A: The executable contained following sections: 1.      Data Section (initialized data variable sec

Explain pros and cons of cpp as a programming language, Write a 3-4 page pa...

Write a 3-4 page paper (350 words per page) in APA format detailing the development and use of C++ in academia and in industry. Explain the pros and cons of C++ as a programming la

Arrays, Write two different arrays. Store the names in it and then compare ...

Write two different arrays. Store the names in it and then compare if both the names entered by the user are the same.

Program to print a series, Write a program called Series that will print/di...

Write a program called Series that will print/display a series of numbers starting with 1 and ending with the last number that is less than 30. The series should include only odd n

Refactoring, Refactoring Project Description: TASK 1 - DESIGN ALGORIT...

Refactoring Project Description: TASK 1 - DESIGN ALGORITHM You are required to design a suitable solution algorithm by using structured chart, pseudocode or flowchart. Thi

Advanced input - output routines, Although we can handle most I/O routines ...

Although we can handle most I/O routines with getc and putc , there are file versions of fgets, fputs, fprintf and fscanf . The syntax is       fgets(stringname,n,filename);   Th

Define external static storage class - computer programming, Define Externa...

Define External Static Storage Class - Computer Programming? An external static is declared outside of all the functions and is obtainable to all functions in that program. The

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd