# Can someone really help to find runtime error in code.

One needs to find No. of squares in a triangle

What you are doing is that for all the t i.e test cases you take the input and then give output for all simultaneously which is wrong.

You need to take input and just after that give output and then again take input and so on.
here is my solution

``````#include<iostream>
``````

using namespace std;

int main()

{

``````int t;cin>>t;

while(t--)

{

int n;

cin>>n;

n=n/2;

n= n-1;

n = (n*(n+1))/2;

cout<<n<<endl;

}
``````

}

What you are doing is that for all the t i.e test cases you take the input and then give output for all simultaneously which is wrong.

You need to take input and just after that give output and then again take input and so on.
here is my solution

``````#include<iostream>
``````

using namespace std;

int main()

{

``````int t;cin>>t;

while(t--)

{

int n;

cin>>n;

n=n/2;

n= n-1;

n = (n*(n+1))/2;

cout<<n<<endl;

}
``````

}
{"ft_lang_label":"__label__en","ft_lang_prob":0.8052149,"math_prob":0.9528818,"size":996,"snap":"2023-14-2023-23","text_gpt3_token_len":285,"char_repetition_ratio":0.11491936,"word_repetition_ratio":0.8414634,"special_character_ratio":0.29819277,"punctuation_ratio":0.15546219,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99679124,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-05-29T11:38:37Z\",\"WARC-Record-ID\":\"<urn:uuid:2d353f8e-e392-431c-acee-723b3f9ab694>\",\"Content-Length\":\"22337\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:59da048f-4ab1-4b17-9450-694c5c6693ba>\",\"WARC-Concurrent-To\":\"<urn:uuid:9b6ba15f-4d01-45da-9928-6c361738fa6c>\",\"WARC-IP-Address\":\"44.215.32.150\",\"WARC-Target-URI\":\"https://discusstest.codechef.com/t/can-someone-really-help-to-find-runtime-error-in-code/10951\",\"WARC-Payload-Digest\":\"sha1:ZCX5CVXIF5HMCPLJ3PQSPWTRRK7UEAHD\",\"WARC-Block-Digest\":\"sha1:ZMBINIKJBHVOP76BDQXR7AYJVUVYW2NK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224644855.6_warc_CC-MAIN-20230529105815-20230529135815-00070.warc.gz\"}"}