Hello **Programmers/Coders,** Today we are going to share ** solutions of Programming problems of HackerRank of Programming Language C **. At Each Problem with Successful submission with

**all Test Cases Passed,**you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight you profile to the recruiters.

In this post, you will find the solution for **Calculate the Nth Term in C-HackerRank Problem**. We are providing the **correct and tested solutions** of coding problems present on **HackerRank**. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

**C **is one of the most widely used **Programming Languages**. it is basically used to build **Operating System**. **C **was developed by **Dennis Ritchie in 1972**. Below are some examples of **C Programming** which might you understanding the **basics of C Programming.**

**Objective**

This challenge will help you learn the concept of recursion.A function that calls itself is known as a recursive function. The C programming language supports recursion. But while using recursion, one needs to be careful to define an exit condition from the function, otherwise it will go into an infinite loop.To prevent infinite recursion,* if….else* statement (or similar approach) can be used where one branch makes the recursive call and other doesn’t.

**Task**

There is a series,* S*, where the next term is the sum of pervious three terms. Given the first three terms of the series,

*,*

**a***, and*

**b***respectively, you have to output the*

**c***n*term of the series using recursion.Recursive method for calculating

^{th}*n*term is given below.

^{th}**Input Format**

- The first line contains a single integer,
.**n** - The next line contains
*3*space-separated integers,,**a**, and**b**.**c**

**Constraints**

**1<=n<=20****1<=a,b,c<=100**

**Output Format**

Print the *n ^{th}* term of the series,

**.**

*S(n)***Sample Input 0**

5123

**Sample Output 0**

11

**Explanation 0**

Consider the following steps:

**S(1) = 1****S(2) = 2****S(3) = 3****S(4) = S(3)+S(2)+S(1)****S(5) = S(4)+S(3)+S(2)**

From steps * 1*,

*,*

**2***and*

**3****4**, we can say

*; Then using value from step*

**S(4) = 3+2+1 = 6***,*

**2***,*

**3***, and*

**4****5**, we get

*; Thus we print the*

**S(5) = 6+3+2 = 11***as our answer.*

**11**Calculate the Nth term – Hacker Rank Solution

#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> //Complete the following function. int find_nth_term(int n, int a, int b, int c) { //Write your code here. int i,arr[100]; arr[1]=a; arr[2]=b; arr[3]=c; for(i=4;i<=n;i++) { arr[i]=arr[i-1]+arr[i-2]+arr[i-3]; } return arr[n]; } int main() { int n, a, b, c; scanf("%d %d %d %d", &n, &a, &b, &c); int ans = find_nth_term(n, a, b, c); printf("%d", ans); return 0; }