Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
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? 2 Set N='A'. What is the result? Does it make sense? Modify the program to make sure that the entered value is numeric. You can do so by using cin.fail() and cin.clear() (see the following for more information. 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. 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.
return 0;
}
What was wrong?
2 Set N='A'. What is the result? Does it make sense? Modify the program to make sure that the entered value is numeric. You can do so by using cin.fail() and cin.clear() (see the following for more information.
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.
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.
A: The simplest way is to use a stringstream: #include #include #include using namespace std; string itos(int i) // convert int to string { stringstream s;
AREA UNDER THE CURVE USING C
A: No. Syntax wise it is permitted. But then the function is no longer Inline. Since the compiler will never know how deep the recursion is at compilation time.
brief note on multiple stack
After p = new Fred[n], how does the compiler know about n objects to be destructed throughout delete[] p? A: The run-time system hold the number of objects, n, somewhere where
Receive 3 numbers and display them in ascending order from smallest to largest ed#
Define Functions with arguments and no return values The calling function will read a data from the terminal and pass it on to called as function and this will work good as the
Explain about the Floating point Constants in c language? A floating point constant is the number that contains either a fraction or decimal part. If an exponent is present its
Yes. "Memory pools" are useful in many situations. The bad news is that I'll need to drag you through the mire of how it acts before we talk about all the uses. Firstly, recall
A Constructive Example Consider an example , to model a user-defined data type for strings. The object simulates a character array ( string ) using a character pointer and an
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!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd