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 8840571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:29:37+00:00 2026-06-14T10:29:37+00:00

Code: int size=0; Scanner in = new Scanner(System.in); System.out.println(Enter size of the Graph); size

  • 0

Code:

int size=0;
Scanner in = new Scanner(System.in);     
System.out.println("Enter size of the Graph");
size = in.nextInt();
System.out.println(size);
for (int i = 1; i <= size; i++) {
    Scanner in2 =new Scanner(System.in);
    while(in2.hasNextInt()){
        int num = in2.nextInt();
        System.out.print("(" + i + "," + num + ")"+",");
        System.out.println();
    }
    System.out.println("out of the while loop");
}

Input & Output:

Enter size of the Graph
4
4
2 3 4
(1,2),
(1,3),
(1,4),
2 5 6
(1,2),
(1,5),
(1,6),

As you can see my program doesn’t exists while loop. It still prints the value for i=1.
What I am doing wrong?

  • 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-14T10:29:39+00:00Added an answer on June 14, 2026 at 10:29 am

    Your program is constantly waiting for a new feed, in order to terminate it – you should indicate the input was ended (or provide a non int input).

    To indicate the feed ended – you should provide EOF – which is ctrl+D in linux and ctrl+Z in windows.

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

Sidebar

Related Questions

Here's my code: public void readFile() throws IOException { System.out.println(Input file name: ); Scanner
here is my code Scanner in = new Scanner(new File(words.txt)); int choice = 0;
The basic pseudo code looks like this: void myFunction() { int size = 10;
Hi, i'm have this code for initialize my class. - (id)initWithSize:(int)size { self =
I'm using gcc 4.3.2. I have the following code (simplified): #include <cstdlib> template<int SIZE>
My code is -(UIImage *)addText:(UIImage *)img text:(NSString *)text1 { int w = img.size.width; int
Having code: int** a = new int*[2]; a[0] = new int(1); a[1] = new
Given the following code: const int size = 20; char buffer[size]; // From the
package homework4; import java.util.Scanner; public class Prog4 { static Scanner scanner = new Scanner(System.in);
System.out.println(-----------------------------------------------------------); System.out.println(Please select a task); System.out.println(1: List employees with details); System.out.println(2: List of clients

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.