Good evening sir Can you help me do problem 4 I know I am as

Good evening sir
Can you help me do problem 4
I know I am asking a lot
Step by step so I can understand it okay
But if you can help me that will be great!
It\'s for C++
Good evening sir
Can you help me do problem 4
I know I am asking a lot
Step by step so I can understand it okay
But if you can help me that will be great!
It\'s for C++
Question 4 write a program that calculates triangle numbers by using a recursive function. A triangle number is the sum of all whole numbers from 1 to N, in which N is the number specified. For example, triangle (5) 5 4 3 2 1. (Lecture 20) Instructions for submission: 1. Each group uploads one set of files, including a word document and a .zip file including the codes. 2. Please write the group member names at the first line of the word document. 3. The zip file is the compressed file of four separate folders including the codes. 4. The word file includes the screen captures of the four programs.

Solution

#include<iostream>

using namespace std;

int triangle(int num);

int main()
{int num, sum;
cout<<\"Enter the integer and i will display triangle value\"<<endl;
cin>>num;
sum = triangle(num);
cout<<\"The triangle value is \"<<sum<<endl;

return 0;

}

int triangle(int num)
{
if(num!=0)
return num+triangle(num-1);

else
return num;
}

 Good evening sir Can you help me do problem 4 I know I am asking a lot Step by step so I can understand it okay But if you can help me that will be great! It\'

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site