--%>

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 : Explain Model-view pattern Model-view

    Model-view pattern: It is a pattern in which the representation of data (that is, the model) is kept separate from its visualization (that is, the view). These decoupling makes it simpler to change the underlying data representation, or give multiple

  • Q : OCIW32 dll error Normal 0 false false

    Normal 0 false false

  • Q : Define the term Protected statement

    Define the term Protected statement: It is a statement within the try clause of the try statement.

  • Q : Grade someone activities Normal 0 false

    Normal 0 false false

  • Q : Define the term Sound card Define the

    Define the term Sound card: It is a hardware device employed to turn digital data into sound.

  • Q : Rings present in CPU What do you mean

    What do you mean by rings present in CPU?

  • Q : Generate source code for an ASP.NET Web

    What is the possibility to generate the source code for an ASP.NET Web service by a WSDL? Answer: The Wsdl.exe tool (as .NET Framework SDK) can be utilized to genera

  • Q : What is Final method Final method :

    Final method: This is a method with the final reserved word in its header. The final method might not be overridden by a method stated in a sub class.

  • Q : Explain features of XSLT programmer Do

    Do you feel that you are a good Extensible Style Sheet Language Transformations programmer?

  • Q : What is Primitive Type Casting

    Primitive Type Casting: C/C++ allows you to cast between totally unrelated types. This can be problematic for model checking. Avoid type casting between unrelated types and in particular primitive types. For example,

    Discover Q & A

    Leading Solution Library
    Avail More Than 1429645 Solved problems, classrooms assignments, textbook's solutions, for quick Downloads
    No hassle, Instant Access
    Start Discovering

    18,76,764

    1937277
    Asked

    3,689

    Active Tutors

    1429645

    Questions
    Answered

    Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!

    Submit Assignment

    ©TutorsGlobe All rights reserved 2022-2023.