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 difference between protected and private?

1071


What are synchronized methods and synchronized statements in java programming?

1014


What is api in java?

974


What is the purpose of format function?

1173


Difference between ‘is-a’ and ‘has-a’ relationship in java?

1006


What are predefined functions?

1131


Can inner class be public in java?

1015


What is difference between stringbuffer and string?

957


How do you generate random numbers in java?

1004


What is runtime polymorphism or dynamic method dispatch?

1004


Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?

1236


What are passing parameters?

1083


Can we make a constructor final?

1015


Is main is a keyword?

997


What is the best definition for data?

971