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

Explain the switch construct, The Switch Construct The switch statement...

The Switch Construct The switch statement is a multi-way decision-making construct that tests an expression matches one of a number of constant values, and branches accordingly

COMPUTER, THEORY OF A COMPUTER PROGRAMMING

THEORY OF A COMPUTER PROGRAMMING

D, drawbacks in assignments in engeenirng

drawbacks in assignments in engeenirng

What is precedence and order of evaluation, Precedence and Order of evaluat...

Precedence and Order of evaluation The languages follow a standard precedence for basic operators. Precedence rules help in deleting ambiguity of the order of operations perfor

Write a program to illustrate the call by reference, Write a Program to ill...

Write a Program to illustrate the Call by Reference? Here is an illustration: #include . int compute_sum(int *n); int main( void) { int n=3, sum; printf("%d\n",n); /

Explain about inheritance, Inheritance and Reuse Consider a car manufac...

Inheritance and Reuse Consider a car manufacturing company. When they require building a new car, they have two choices. They can start from the scratch, or they can change an

Develop a .net wrapper for a c++ dll, Develop a .NET wrapper for a C++ Dll ...

Develop a .NET wrapper for a C++ Dll Project Description: We have a classic VC++ Dll that requires a .NET wrapper built by you. Use latest Visual Studio and .Net framework sh

Write a program that reads data from array, Write a program that reads data...

Write a program that reads data into an array of type int. You must use an array. The numbers input are attendance numbers at a conference. Keep a running average, number of events

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