NZEC in java

This is the first ever programmer i have tried in java.after learning basics… But i am getting error saying that NZEC.Then i found out that this was related to return type or other return problem…can anyone help me in removing this error.i have written the code below.plz give me a immediate reply\


import java.util.Scanner;
class Codechef
public static void main (String[] args)
int ctr; int n;double a[]=new double[20];

    Scanner input=new Scanner(;
    for(int i=0;i<n;i++)
{ ctr=0;



Always provide the problem link while asking for a doubt.

There are two problems in your code:

  1. According to the constraints, 1 <= T <= 10^{5}, but you have declared your array to be of size 20. So, change the size of the array to 10^{5}.
  2. The data type of your array is double, but you are trying to get the last digit of the number by taking the mod and dividing it by 10. This method works only with integers, not with floating-point value. So, change the data type of the array to int.

After doing these changes, your code will work fine.

EDIT1: Here is the corrected code

import java.util.*;
class TestClass {
public static void main(String args[] ){
Scanner s = new Scanner(;
int c = s.nextInt();

            int count=0;
            String c1 = s.nextLine();
            for (int i=0;i<c1.length() ;i++ ) {
                if(c1.charAt(i) == '4'){

plz reply fast guys

What is the question??

CAN u change the code and i have tried it is not working.plz do it fast

I’ve updated the answer and added the code.

thnks a lot

Hey, you don’t need to award any points. By this, you are losing your karma. You can rather upvote and accept an answer. This way, you will gain karma points and still be grateful.


Please refrain from using award point feature of forum for accepting answer. Just click on that “tick in circle” below “thumbs down button” to accept his answer and grant him the deserved karma. :slight_smile: