--%>

Calculate the summation of 1 to some integer n

Write two programs to calculate the summation of 1 to some integer n using a function called

int summation(int n)

a) Using a non recursive solution, with a for(i=1, i<=n; i++) loop and b) using a recursive solution, based on the following conditions summation(n) = summation(n-1) + n, if n>0 summation(n) = 0, if n = 0

 

 

   Related Questions in Programming Languages

  • Q : Describe tri-state devices Describe the

    Describe the tri-state devices and explain why they are necessary in a bus oriented system?

  • Q : Program to controls a quiz show in C++

    Foundations of Computer Science In this project, we will write a program that controls a quiz show, much like the many popular TV shows. The program will read in a group of questions and thei

  • Q : Explain Imperative programming

    Imperative programming: The style of programming generally related with languages such as FORTRAN, C, Pascal and so forth. Imperative programming is differentiated from functional programming in that the previous is strongly tied to the idea of variab

  • Q : Explain Parallel programming Parallel

    Parallel programming: It is a style of programming in which statements are not essentially executed in an ordered series but in parallel. The parallel programming languages make it simpler to produce programs which are designed to be run on multi-proc

  • Q : Problem on COBOL if sentence Write a

    Write a COBOL IF sentence to use the values of numeric variables EXAM and COURSEWORK, both assumed to be with format PIC 999 and in the range 0 to 100 and to move the value:“FAIL”, “RC” ( resit coursework), “RE” (r

  • Q : Explain the way to back-up active

    Explain the way to back-up active directory.

  • Q : Choices in the Choice Activity Normal 0

    Normal 0 false false

  • Q : Explain a quality and metrics reporting

    What opinion would you provide to someone who asked you where to begin to introduce to their company a quality and metrics reporting program?

  • Q : How is an external entity reference

    While constructing an XML DTD, how do you make an external entity reference within an attribute value?

  • Q : Define the term Identifier Define the

    Define the term Identifier: It is a programmer-defined name for a method, variable, class and interface.