Search This Blog

Popular Posts

Wednesday, December 21, 2011

Basic of programming SOLUTIONS 1 TCS ASPIRE

//Improve the understandability of the below given code:



import java.util.*; /* it is importing all class in java.util package */

class problem3 /* creating a class problem3 */

{ /* opening braces for class problem3 */

int[] numArray = new int[10]; /* declaring an array of integer named numArray & is assigned with 10 element */

public static void incrementElements (int[] integerArray) /* a method named incrementElements whose return type
void it means it is not returning any value.
Static means it can be automaticaly called.
public means it can be called anywhere in the program.
passing parameter array of integer */

{ /* opening braces for method incrementElements */

int arraylen = integerArray.length; /* arraylen is any variable of data type integer which
calculated lenght of array by using integerArray.length */

for (int i = 0; i < arraylen; i ++) /* a loop stating from i=0 to lenght of array and increment every time
by +1 */

{

System.out.println(integerArray[i]); /* printing present integer value of array */

}

for (int i = 0; i < arraylen; i ++) /* same foor loop is called */

{

integerArray[i] = integerArray[i] + 10; /* printing value by increamenting 10 in each present value of array */

}

for (int i=0; i < arraylen; i ++) /* same foor loop is called */

{

System.out.println(integerArray[i]); /* last printed value will be reprint */

}

}

1 comment:

  1. hey,,i want answers of basics of programming from test and quiz

    ReplyDelete