plz help me today plz plz
2.) Suppose list is an array of six elements of type int. What is stored in list after the following java code executes?
.
for (i = 0; i < 5; i++)
{
list[i] = 2 * i + 5;
if (i % 2 == 0)
list[i] = list[i] - 3;
}
.
3.) What is the output of the following program?
.
public class exercise6
{
public static void main(String[] args)
{
int count;
int[] alpha = new int[5];
alpha[0] = 5;
for (count = 1; count < 5 * count ++)
{
alpha[count] = 5 * count + 10;
alpha[count - 1] = alpha[count] - 4;
}
System.out.print("List elements: ");
for (count = 0; count < 5; count++)
System.out.print(alpha[count] + " ");
System.out.println();
}
}
View Answers
March 30, 2010 at 10:08 AM
Hi Friend,
1)public class Example{
public static void main(String[]args){
int list[]=new int[5];
for (int i = 0; i < 5; i++){
list[i] = 2 * i + 5;
if (i % 2 == 0){
list[i] = list[i] - 3;
System.out.println(list[i]);
}
}
}
}
Output of above code is:
2
6
10
Explanation-In the above code, firstly the array stores the value of i after multiplying with 2 and adding with 5.
If the value of i after dividing it with 2 results 0 then subtract this array value by 3.
2)public class Example{
public static void main(String[]args){
int count;
int[] alpha = new int[5];
alpha[0] = 5;
for (count = 1; count < 5 ; count ++){
alpha[count] = 5 * count + 10;
alpha[count - 1] = alpha[count] - 4;
}
System.out.println("List elements: ");
for (count = 0; count < 5; count++)
System.out.println(alpha[count] + " ");
}
}
Output of above is:
11
16
21
26
30
Expalanation- Here you have declared the first value of array.Firstly the array stores the value of count after multiplying with 5 and adding with 10. And then subtract this array value by 4 and store in the previous array index. This will continue till you will get all the array values.
Related Tutorials/Questions & Answers:
Help me quickly plz??Help me quickly
plz?? Can you
help me to write code quickly this code is a java code take input as double and should use command line arguments and enhanced for statement then find the combine of the numbers
plz help quickly
Advertisements
plz help me for this questionplz help me for this question Apply simplex procedure to solve the L.P.P. maximize z = 3x1 + 4x2 subject to 5x1 + 4x2 â?¤ 200; 3x1 + 5x2 â?¤ 150; 5x1 + 4x2 â?¥ 100; 8x1 + 4x2 â?â?¥ 80, x1 â?¥ 0, x2 â?¥ 0
plz help me - Java Beginnersplz help me Deepak I can write a sessioon code
plz help me admin_home.jsp page is display but data is not disply
plz help me what is wrong
Plz Help MePlz Help Me Write a program for traffic light tool to manage time giving between Main-Street and sub-Street. firstly, give green light for 40... traffic light on the frame. We have used java swing. It may
help you.
import
plz help me - Java Beginnersplz help me Hi,
I want to search all field from database using name, and display in text box, then data is update and delete.
i want to search name using alphabets a-z,
plz reply fast.
plz help me this is very urgent
plz Help me - Java Beginnersplz Help me Hi,
I want learn struts,I dont have any idea about this
plz help how can i make a framework.If u have any information then
plz send my personal id
plz tell
me that whose software installed.and give
me brief
plz help me - Java Beginnersplz help me Thanks deepak continue response..i face some problem
i... is true...but i very confuse that how it is not displayed admin page
plz any one give
me reponse my persinal given id Hi ragni,
i am sending
plz help me - Java Beginnersplz help me deepak hw can i create a data grid in jsp and also how can i connect to the data base
plz help me to create data grid in jsp use html tables with borders.
to connect to data base use scriptlets.
ex
plz help me!!!!!!!! - JSP-Servletplz help me!!!!!!!! i`ve set the environment varaibles for tomcat as well as jdk.. but i`m not understanding where i`ve to save my servlet..i.e.... there are compilation errors..
plz do
help me. make sure that you did
help today plz:( - Java Interview Questionshelp today plz:( write a program that promptes the user to enter the weight of a package in pounds, and then outputs the weight of the backage in to kilograms
(one kilogram is approximately, 2.2 pounds)?
but i don't use
Plz HelpPlz Help Hello Guys!!
Plz.
Help
I need to write a program to display the astrological sign based on your birthday for example
If we enter the date of birth in the following format from console--13/08/1990
it should give you
plz helpplz help what is the procedure and code to design an interactive GUI in java using swings
plz give me answer plzplz give
me answer plz writw a programme to find rank from an array using doubledimmensionalarray
Intranet Website creation - plz help me Intranet Website creation -
plz help me hi..
I have assign with the intranet website creation work..right from scratch to end..And honestly I know nothing about it.My domain is totally different ..
can anybody pls
help me facing problem plz help me out - FrameworkFacing problem
plz help me out hi i am new to servlet i deployed... the web.xml file too parallel to the classes folder now i am facing this problem.plz tell
me what to do... error:The requested resource (Servlet servlet
PLZ HELP ME. i need php code. PLZ HELP ME. i need php code. I want php code for bellow OUTPUT.
output is just example but it must be letters only.
abc
bcd
efg
jku
rgt
azs
hje
qqc
wws
adt
help me plz befor 27 februryhelp me plz befor 27 februry what is rung with this ??
help me plzzzz
import java.util.Scanner;
public class Initials
{
public static void main (String [] args)
{
String firstname,lastname
Plz help me with this Question - Java BeginnersPlz help me with this Question this is java code
-------------------------
Consider the following code:
int [ ] a = [1, 2, 3];
Object o ="123";
String t = "12";
String w = t + "3";
Boolean b = o.equals (a);
Boolean b2
help me plz - Java Interview Questionshelp me plz 1)write a java program that prompts the user to input a decimal number and print the number rounded to the nearest integer?
2)write...?
plz answer my question Hi Friend,
Try the following code:
1
interview question plz help me and thersinterview question
plz help me and thers A college is good if it satisfies the following conditions:
1.Its number of students is greater than 1000.
2.If the name ends wih a character 'e', then it should not start with character
plz Help me find the correct programs answersplz Help me find the correct programs answers
Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff... INDICA" and "TATA NANO" respectively.
Plz mail
me your answers
plz give me answerplz give
me answer description about string class methods
Java string methods
plz give me answerplz give
me answer description about string class methods
Java string methods
plz give me answerplz give
me answer description about string class methods
Java string methods
plz help me - Java Interview Questionsplz help me 1)Rewrite the method in exercise 10 such that it use the binary search algorithm instead.
the linear search algorithm is suitable for small arrays or unsorted arrays.
for large arrays linear search is inefficient
java, plz help me in doing this - Java Beginnersjava,
plz help me in doing this # Write a small record management application for a school. Tasks will be Add Record, Edit Record, Delete Record.....giving
me the error of NoClassDefFoundError
plz give me answerplz give
me answer Discuss & Give brief description about string class methods
Java string methods
Plz Plz reply Me - JSP-ServletPlz Plz reply Me Respected Sir/madam,
I am R.Ragavendran.. Actually I got your coding.. But This code is not enabling the user to click and change the image..
I request you to remember the code which you have provided for
me plz tell meplz tell me how to get no. of times the 'button' is pressed
Here is a java swing code that counts the number of times the button clicked... CountButtonClicks();
}
JButton button1 = new JButton("Click
Me!");
int clickCount
java coding help plz ?java coding
help plz ? Given two integers N and M (N � M), output all the prime numbers between N and M inclusive, one per line.
N and M will be positive integers less than or equal to 1,000,000,000.
The difference
Gui plz help Gui
plz help Create a Java application that would allow a person to practice math (either addition, subtraction, multiplication or division). The questions must be randomly generated ( the values for each number should
plz help me to create gui using Java netbeansplz help me to create gui using Java netbeans Hi,
I am unable to fetch a particular data from DB.I am using netbeans for creating GUI. If I want.... I am unable to fetch the particular data.
Plz help me
Hi Friend
plz help - Java Beginnersplz help i have to programs and it takes too long to run them so i got a solution that makes programs run much faster which is threading programming..
but i dont know how to aplly that on my 2 programs:
the first code
Plz give me code for this questionPlz give
me code for this question Program to find depth of the file in a directory and list all files those are having more number of parent directories
population problem plz help me befor 16 March 2011 !!population problem
plz help me befor 16 March 2011 !! the
Q is :
How can i count how many years it will take for the population of a town to go over 30.000 .. consider that it Increases 10% every year ??
And this is my code &
Plz send me answer qucklyPlz send
me answer quckly Respected Sir,
myself is pavan shrivastava.i want ask a question that is ( we can't
create object of interface then how would possible to create object