class Solution {
public:
int nthTermOfAP(int A1, int A2, int N) {
int d=A2-A1;
int current=A1;
int arr[10];
for (int i=0;i<N;i++)
{
arr[i]=current;
current+d;
}
cout<<arr[N-1];
}
};
// { Driver Code Starts.
int main() {
int t;
cin >> t;
while (t--) {
int A1, A2, N;
cin >> A1 >> A2 >> N;
Solution ob;
cout << ob.nthTermOfAP(A1, A2, N) << "\n";
}
}
// } Driver Code Ends
i am getting output as 26295968. Please explain why i am getting such a large number? do i have to intialize any number to 0?