Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to print a numbers from 1 to 100 with out using control
structures?

Answer Posted / gayitri91

import java.io.*;

class Sample

{

public void printTo100(){
int[] array = new int[101];
try{
printToArrayLimit(array, 1);
}catch(ArrayIndexOutOfBoundsException e){
}
}
public void printToArrayLimit(int array[] , int index){
array[index] = array[index-1]+1;
System.out.println(array[index]);
printToArrayLimit(array, index+1);
}




public static void main(String ar[])
{
Sample s=new Sample();
s.printTo100();
}
}

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string builder in java?

1014


What is the relationship between class and object?

1045


Write a java program to count the number of words present in a string?

982


Does it matter in what order catch statements for filenotfoundexception and ioexception are written?

953


Which is bigger float or double java?

978


Is there a jre for java 11?

1085


Why is an interface be able to extend more than one interface but a class can’t extend more than one class?

1169


What is java algorithm?

940


Differentiate between a constructor and a method? Can we mark constructors final?

1195


What is implicit object in java?

1078


Can we create our own wrapper class in java?

968


How to make a read-only class in java?

1161


What is the difference between yield() and sleep()?

1014


What is command line argument

1195


What is multi level inheritance in java?

1028