Question: Design a program in C which, when executed, will do the following in the indicated sequence: Ask the user to type on the keyboard a
Design a program in C which, when executed, will do the following in the indicated sequence:
Ask the user to type on the keyboard a user-supplied positive integer number nstart and a user-supplied larger positive integer number nstop.
The program will then compute for one time only, using the while looping command, the value of the function called xNo(nstart,nstop) which is defined as the sum of all the integers lying between and including nstart and nstop, i.e.,
xNo(nstart,nstop) = nstart + (nstart+1) + (nstart+2) + + (nstop-1) + nstop.
As an example, let nstart=2 and nstop=5, then xNo(2,5)=2 + 3 + 4 +5=14.
If you select nstart=1 and nstop=n, then the function xNo(nstart,nstop) simply reduces to the triangular number of n, i.e., xNo(1,n)=1+2+3++ (n-1) +n. Thus, the function xNo(nstart,nstop) may be viewed upon as a general case of the triangular number of a positive integer number.
The program is then to display on the console the user-supplied values of nstart and nstop as well as the corresponding value of xNo(nstart,nstop) in the format shown below:
nstart=2 & nstop=5 ====> xNo(2,5)=14.
Modify program 1 above so that it computes and then displays on the console computations of xNo(nstart,nstop) for user-specified values of nstart and nstop as in Program 1 but now in an infinite loop.
Note that, when you go through a loop, the program asks the user to type on the keyboard values of nstart and nstop, and then generates the corresponding value of xNo.
Modify the original program above so that it computes and then displays on the console computations of xNo(nstart,nstop) for user-specified values of nstart and nstop as in Program 1 but now for a user-specified number of times denoted noOfTimes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
