# Help me in solving SMILEY problem

### My code

``````#include <stdio.h>

int main(void) {
int t;
scanf("%d", &t);

for (t;t>0;t--){
int n;
scanf("%d", &n);
char arr[n+2];
int colon[n+2];
int cc=0;
int happyc=0;
int ans=0;

for (int c=0; c<n+1;c++){
scanf("%c", &arr[c]);
if (arr[c]==':'){
colon[cc]=c;
cc+=1;
}
}
for(int c=0;c<cc-1;c++){
happyc=0;
for (int l=colon[c]+1; l<colon[c+1];l++){
if (arr[l]==')'){
happyc+=1;
}
else{
}
}
if (sadc == 0 && happyc>0){
ans+=1;
}
}
for (int j=colon[cc-1];j<=n;j++){
happyc = 0;
if (arr[j]==')'){
happyc+=1;
}
else{
}

}
if (sadc == 0 && happyc>0){
ans+=1;
}

printf("%d\n", ans);
}
return 0;
}

``````

Problem Link: SMILEY Problem - CodeChef

@kanavkapoor
just few little mistake take input in the form of string outside the loop cozz taking it inside its counting some extra spaces .
include <stdio.h>

int main(void) {
int t;
scanf(ā%dā, &t);

``````for (t;t>0;t--){
int n;
scanf("%d", &n);
char arr[n];
int colon[n];
int cc=0;
int happyc=0;
int ans=0;
scanf("%s",arr);
for (int c=0; c<n;c++){
if (arr[c]==':'){
colon[cc]=c;
cc+=1;
}
}
for(int c=0;c<cc-1;c++){
happyc=0;
for (int l=colon[c]+1; l<colon[c+1];l++){
if (arr[l]==')'){
happyc+=1;
}
else{
}
}
if (sadc == 0 && happyc>0){
ans+=1;
}
}
for (int j=colon[cc-1];j<=n;j++){
happyc = 0;
if (arr[j]==')'){
happyc+=1;
}
else{