We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C
- Functions
- Calculate the Nth term
- Discussions
Calculate the Nth term
Calculate the Nth term
Sort by
recency
|
817 Discussions
|
Please Login in order to post a comment
include
int find_nth_term(int n, int a, int b, int c) { int sum[n],count; sum[0]=a,sum[1]=b,sum[2]=c; for(int i=3;i
include
include
include
include
//Complete the following function.
int find_nth_term(int n, int a, int b, int c) { int term, t1 = a, t2 = b, t3 = c; if (n == 1) term = t1; else if (n == 2) term = t2; else if (n == 3) term = t3; else { for (int i = 4; i <= n; i++) { term = t1 + t2 + t3; t1 = t2; t2 = t3; t3 = term; } } return term; }
int main() { int n, a, b, c;
}
include
include
include
include
//Complete the following function.
int find_nth_term(int n, int a, int b, int c) { int term, t1 = a, t2 = b, t3 = c; if (n == 1) term = t1; else if (n == 2) term = t2; else if (n == 3) term = t3; else { for (int i = 4; i <= n; i++) { term = t1 + t2 + t3; t1 = t2; t2 = t3; t3 = term; } } return term; }
int main() { int n, a, b, c;
}