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

How to optimize the javac output?

1098


Can singleton class be serialized?

1011


What is jpa specification?

1031


What will happen when using pass by reference in java?

1043


What is numel matlab?

1411


What is the common usage of serialization?

1225


What is prefix of a string?

1084


What is a JAR file?

1106


Explain polymorphism citing an example.

1103


When should I use stringbuffer?

1056


What is the difference amongst jvm spec, jvm implementation, jvm runtime ?

1021


What is the exact difference in between unicast and multicast object? Where we will use?

1044


How does java pattern compile work?

1022


Which command from the jdk compiles a java program?

1046


Can we assign integer value to char in java?

1084