Comprogzz programming

The following coding in Java will input a number from the user. Let the number be 30.

 import java.io.*;
      class General_consc14{
      public static void main(String args[])throws IOException
            {
             int n;
              InputStreamReader isr=new InputStreamReader(System.in);
               BufferedReader br=new BufferedReader(isr);
               do{
               System.out.println("Enter a number");
      n=Integer.parseInt(br.readLine());
}while(n<=0);
for(int i=1;i<=(n-1);i++)
{
    int s=0;
    for(int j=i;j<=n;j++)
    {
        s+=j;
        if(s==n)
        {
            for(int k=i;k<=j;k++)
            {
                System.out.print(k+",");
            }
            System.out.println();
        }
    }
}

} }

the output of the coding when entered number is 30:-- 4,5,6,7,8 6,7,8,9 9,10,a

find the number which in indicated by 'a' .

[ hint:-

log on to www.comprogzz.in then select "Programs on Java" option then select "General programs" option then find program number 14 and select it. u will observe the example which will give u the solution.. ]

×

Problem Loading...

Note Loading...

Set Loading...