Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8750933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:57:08+00:00 2026-06-13T12:57:08+00:00

This code keeps giving me a dead code warning on the i++ in the

  • 0

This code keeps giving me a dead code warning on the i++ in the for loop and it is not incrementing the i for some reason!

import java.util.Scanner;


public class HideThatNumber {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int enc=input.nextInt();
        int tur=0;
        String test="";
        double x;
        for (int i=1;i<10;i++){
            test="";
            test+=i;
            test+=enc;
            x=Integer.parseInt(test);
            x/=11;
            if(x==Math.round(x));{
                tur=i;
                break;
            }
        }
        if(tur==0)
            System.out.println("Impossible");
        else 
            System.out.println(Integer.parseInt(test)/11);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:57:09+00:00Added an answer on June 13, 2026 at 12:57 pm
        if(x==Math.round(x)); <--semi-colon
        {
            tur=i;
            break;
        }
    

    Inside your for loop, you have put a semi-colon at the end of your if. Thus the next block of code will be executed in any case, and thus you would break out of your loop after the first iteration.

        {
            tur=i;
            break;
        }
    

    This block will be executed regardless of what your if condition evaluate to. And you break out of the loop.

    And hence you get the warning, because i++ will never be executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code it keeps giving me error Protected Sub Button2_Click(ByVal sender As
I tried to use some code from the documentation, but it keeps giving me
My markup And this JQuery code keeps on giving me error each time I
I am trying to get this code working in ember but it keeps giving
For some reason, the following code does not work: char cValue = '8'; int
The following code keeps giving me this error Parse error: syntax error, unexpected T_VARIABLE
Trying to import a custom UITableViewCell and it keeps giving me a file not
I am attempting open a csv file with this code and it keeps giving
This code of mine keeps on throwing error i don't understand why. var id
This is driving me crazy... With this simple code I keep getting file not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.