Delhi's odd even

Question: https://hack.codingblocks.com/contests/c/456/59
Answer:
#include
using namespace std;

int main() {

int n,i, se = 0, so = 0, r;
//so=sum of odd 
// se = sun of even 
cin>> n ;
 int arr [n];
 n<=1000;
 bool flag = 1 ;

 for(i=0;i<n;i++){
    cin >> arr[i] ;
 }

while (n > 0) {
    r = n % 10;
    if (r % 2 == 0) {
        se = se + r;
    } else {
        so = so + r;
    }
    n = n / 10;



if((se % 4 == 0) || (so % 3==0)){
    bool (flag = 1) ;
    //cout << arr[i] << endl ;
    cout << "Yes" << endl ;
}

if((se % 4 != 0) || (so % 3!= 0)){
flag != 1 ;
cout << ā€œNoā€;
}
}

return 0;

}

plz error!

n is no of test cases and you are assuming that it contains an array element because you are using while(n>0).
You havenā€™t initialized se=0 and so=0 for each element
And, there are some compilation errors in your code

As you are taking n as number of test cases and int the while loop u are using n but u have entered number in the array so in the while loop instead of n use the elements u have entered in arrayā€¦
beacause n are the number of test cases but the actual number of car are stored in the array

again wrong answers!

Send your code after saving it in the ide of coding blocks

https://ide.codingblocks.com/#/s/16247

why you are using ā€˜nā€™ as your car no?
Because your nos that have been entered are being saved in an array arr[]
Suppose the input is:
2
12345
12134
Then you are saving n=2 and in arr[0] = 12345 , arr[1]=12134
And now you are calculating sum of even and odd digits of n (which is not correct).
This problem requires to find whether arr[0], arr[1],ā€¦arr[n-1] is allowed to run on Sunday or not, based on the rule given in problem statement

can u send the code.
Im not getting thisā€¦

https://ide.codingblocks.com/#/s/16312
shivam i have marked your mistakes just check them out

again itā€™s wrong answers!

https://ide.codingblocks.com/#/s/16407
try this

1 Like

thanks .
fine now itā€™s working. mene kha pe mistake kiya tha .

ok i will comment your mistake in your code and then post it

okk thankā€¦

https://ide.codingblocks.com/#/s/21951

i am getting correct output for sample testcases but it is giving wrong answer after submitting

@Ashwini-Rao-12824545
In your code you are checking if the index ā€œiā€ is even or odd, but you need to check if the number t that index is even or odd.
You misinterpreted the question statement.

The simple and easy approach to this question is this
https://ide.codingblocks.com/#/s/16407
Refer this in case of doubt.

What is n in the code?