Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Good evening sir Can you help me do problem 4 I know I am asking a lot Step by s

ID: 3779743 • Letter: G

Question

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.

Explanation / Answer

#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;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote