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 are the types of inner classes (non-static nested class) used in java?

1010


How can we make a class singleton?

1001


What is java volatile?

959


What is style and indentation?

953


What is implicit object in java?

1022


What does yield method of the thread class do?

972


What exceptions occur during serialization?

1032


What is final modifier?

985


In which order the iterator iterates over collection?

945


What are the two types of exceptions in java? Which are the differences between them?

1035


Can we declare a static variable inside a method?

954


What is an array in java?

1126


What are different exception types exceptions available in java ?

949


What is public static?

976


Which variables are stored in heap?

973