# CPP Program Circular List of Students – Adhoc Problems

You are given a circular list of students as follows:

0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 -> 11

• This list is circular, which means that 11 will follow 0 again.
• You will be given the student number ‘i’ and some position ‘p’.
• You will have to tell that if the list will start from (i+1)th student, then which student will be at pth position.

Input Format:

• The first line will have an integer ‘t’, denoting the number of test cases.
• The next line will have two space-separated integers denoting the value of ‘i’ and ‘p’ respectively.

Output Format:

• Print ‘t’ lines containing a single integer denoting the student number.

Constraints:

1 <= t <= 10^5 0 <= i <= 11 1 <= p <= 12

Sample Input:

`2 2 3 5 8 `

Sample Output:

`5 1 `

Explanation:

• First, list will start at 3. 3 -> 4 -> 5. Hence, 5 will be at the third position.
• Second, list will start at 6. 6 -> 7 -> 8 -> 9 -> 10 -> 11 -> 0 -> 1. Hence, 1 will be in the 8th position.

## Code:

```.wp-block-code {
border: 0;
}

.wp-block-code > div {
overflow: auto;
}

.shcb-language {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
position: absolute;
width: 1px;
word-wrap: normal;
word-break: normal;
}

.hljs {
box-sizing: border-box;
}

.hljs.shcb-code-table {
display: table;
width: 100%;
}

.hljs.shcb-code-table > .shcb-loc {
color: inherit;
display: table-row;
width: 100%;
}

.hljs.shcb-code-table .shcb-loc > span {
display: table-cell;
}

.wp-block-code code.hljs:not(.shcb-wrap-lines) {
white-space: pre;
}

.wp-block-code code.hljs.shcb-wrap-lines {
white-space: pre-wrap;
}

.hljs.shcb-line-numbers {
border-spacing: 0;
counter-reset: line;
}

.hljs.shcb-line-numbers > .shcb-loc {
counter-increment: line;
}

.hljs.shcb-line-numbers .shcb-loc > span {
}

.hljs.shcb-line-numbers .shcb-loc::before {
border-right: 1px solid #ddd;
content: counter(line);
display: table-cell;
text-align: right;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
width: 1%;
}
```#include<iostream>
using namespace std;
int calculate(int i, int p)
{
int current_student = i+1;
while(p--)
{
if(current_student>11)
{
current_student = 0;
}
current_student++;
}
current_student--;
if(current_student==-1)
{
current_student = 11;
}
return current_student;
}
int main()
{
int t;
cin >> t;
while (t--)
{
int i, p;
cin >> i >> p;
cout<<calculate(i, p)<<endl;
}
}
```Code language: C/AL (cal)```