--%>

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 : How XML web services integrate two

    How can XML web services integrate two legacy distributed systems, one based on Corba and one based on Java RMI?

  • Q : Kernel Mode Illustrate what are the

    Illustrate what are the different functions of Kernel Mode, interrupts and system calls?

  • Q : Windows Communication Foundation or WCF

    Why did Microsoft develop the Windows Communication Foundation (WCF) technology?

  • Q : Define Interpretational inner class

    Interpretational inner class: It is an inner class whose role is to give a view or interpretation of data belongs to its enclosing class, however independent of the data's real representation.

  • Q : Subroutine in the programming Describe

    Describe the number of ways that an argument is passed to a subroutine in the programming?

  • Q : Define Daemon thread Daemon thread :

    Daemon thread: The daemon threads are non-user threads. They are usually employed to carry out low-priority tasks which must not take priority over the major task of the program. They can be employed to do helpful work whenever all other user threads

  • Q : State De Morgans Theorem De Morgan's

    De Morgan's Theorem: The two rules which can help to simplify Boolean expressions comprising multiple logical-not operators in combination with the other Boolean operators.

  • Q : Perform Exception Handling with

    On occasion, some of Brewbean’s customers mistakenly leave an item out of a basket already checked out, therefore they create a new basket containing the missing items. Though they request that the baskets be combined and hence they are not charged extra shippin

  • Q : Mission Critical Systems or a real-time

    Determine the important aspect of Mission Critical Systems or a real-time system.

  • Q : Examples of applications which can

    Give some examples of applications which can benefit from using XML?