Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions print the sum of even number from 1 to 100

Have Programming Question? Ask it here!
 
 
 


rhoxart faye rosario
print the sum of even number from 1 to 100
1 Answer(s)      3 years and 3 months ago
Posted in : Java Interview Questions


how to print the sum of even number from 1 to 100 using for loops?

Thanks.


Advertisement
View Answers

February 8, 2011 at 3:23 PM


Java print the sum of even number from 1 to 100

class Loops{
    public static void main(String[] args){
        int sum=0;
        for(int i=1;i<=100;i++){
            if(i%2==0){
                System.out.println(i);
                sum+=i;
            }
        }
        System.out.println("Sum of even numbers: "+sum);

    }
}


Related Tutorials/Questions & Answers:
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
Generate random numbers from 1 to 100
Generate random numbers from 1 to 100  1)A class Called: RandomNumberGenerator that generate random numbers from 1 to 100 2)A class Test that tests... an object from the Random NumberGenerator class to generate your input test data
Advertisements
print 100 numbers using loops
print 100 numbers using loops  how to print from 1 to 100 using...{ public static void main(String[] args){ for(int i=1;i<=100;i...[] args){ for(int i=1;i<=100;i++){ System.out.println(i
print the even numbers between the range 100-200
print the even numbers between the range 100-200  Q ?write an application that print out the even numbers between the range 100-200 ? 1- which aer... prints out the even numbers between the range of 100 and 200 and then determine
Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum separately. To do this, first of all, we have found all the even and odd numbers from 1
Check even or odd number.
the condition of num divisibility. If divisible then it will print even number else...Check even or odd number.  How to check given number is even or odd...){ System.out.println("Number is Even"); } else
write an application that print out the even numbers between the range 100-200
write an application that print out the even numbers between the range 100-200   write an application that print out the even numbers between the range 100-200 ?   The given code accepts the number from 100 to 200
how to print all possible combination that sum to zero??
. Print all possible combinations that sum to zero Example Enter a num : 7 1...how to print all possible combination that sum to zero??  ? Consider the sequence of digits from 1 through N (N<=9) in increasing order: 1 2 3
JSTL - check odd/even number - JSP-Servlet
to generate random numbers and to check whether they are odd/even and print "this is an even (odd) number and it is in between so and so number? e.g. the random number is 4. It is an even number between 3 and 5. Much thanks all!  Hi
print square of any number
print square of any number  using c++ language, write aprogram to print the square of any number entered by the user
A program to find the sum of odd number
A program to find the sum of odd number In this section you will learn how to find the sum of odd number in the series up to the given number in java... number. import java.util.Scanner; public class Sum { public static
Prime Number program in Java
Prime Number program in Java will print the prime numbers between 1 to any... automatically prints Prime Number starting from 1 to 50. Example of Prime Number... + " "); } } } Output: Prime Number from 1 to 50 1 2 3 5 7 11 13 17 19 23 29 31 37 41 43
pie chart flex and sum from hql request
pie chart flex and sum from hql request  hi, i work with flex... d.intituleDeleg,SUM(s.usagePedag ),ROUND((((SUM(s.usagePedag ))/(SUM(s.ordidispo)))*100),0), SUM(s.ordidispo) from Statistiqueordinateur s,Delegation d,Etablissement e
Sum of a Number using Swing
Sum of a Number using Swing       In this section, you will learn how to sum of a number using swing...;); Step: Create a file "Calculate.java" to sum of a number using
WAP in java to print the series 1*2*3
WAP in java to print the series 1*2*3  WAP in java to print the series 123
sum
sum  a program to find the sum of the alternative diagit of it ex- no=123456 sum=1+3+5=9
to read number from user
to read number from user  1)print the positive equivalent of the number 2) check if the no is integer or not 3) find the square root of the number 4) find the cube of the number
Sequence number to generate daily starting with 1
Sequence number to generate daily starting with 1  Sir, I am creating a bill report Application..I want to generate a sequence number for bill that is starting from 1.and if date changes the sequence number again starts with 1
Check whether highest number is even or odd
Check whether highest number is even or odd In this section, you will learn... that if the highest number is totally divided by 2,then it is even, otherwise...("Highest Number " + highestNumber + " is Even"); } else { System.out.println
Check whether the sum of alternate digit of a number is palindrome or not.
Check whether the sum of alternate digit of a number is palindrome... are going to check whether the sum of the alternate digit of a number entered... of the alternate digits of number (like if a number is 23456, the sum of alternate digit
Find consecutive numbers whose sum is equal to input number.
Find consecutive numbers whose sum is equal to input number. In this section... numbers which sum up to given number. Here is the code: import java.util.... a number"); num = input.nextInt(); for (int i = 1; i < num; i
sum
sum  s=1+12+123+1234+............+123....n terms   import...: "); int n=input.nextInt(); int s=1,sum=1; System.out.print("The series : 1+"); for(int i=2;i<=n;i++){ s=(s*10)+i
Count number of occurences and print names alphabetically in Java
Count number of occurences and print names alphabetically in Java  I... for the printCount() method for the code to count the number of occurences of each word and print in alphabetical order to produce this output: {bob=1, jim=1, tim=1
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement  hi class Even{ public static void main(String[] arg){ int num=Integer.parseInt
loop code to print the Pyramid: 1 1234 12 123 123 12 1234 1
loop code to print the Pyramid: 1 1234 12 123 123 12 1234 1  Hi, I want to know how the code to print the pyramid below works. It uses nested for loops. Pyramid: 1 1234 12 123 123 12 1234 1
sum
sum  s=1/(1+2)+1/(1+2+3)+1/(1+2+3+4)+.....+1/(1+2+3+....n terms
sum
sum  s=1/(1+2)+1/(1+2+3)+1/(1+2+3+4)+.....+1/(1+2+3+....n terms
Sum of integers
Sum of integers  A Java program that reads an integer value from the user and displays i) the sum of all even integers between 1 and the input value, both inclusive. ii) The sum of all odd integers between 1 and the input
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code sample"); package bankprj3; class Account { private double Balance; public Account(double initBalance){ Balance=initBalance; } public
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code sample"); package bankprj3; class Account { private double Balance; public Account(double initBalance){ Balance=initBalance; } public
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code sample"); package bankprj3; class Account { private double Balance; public Account(double initBalance){ Balance=initBalance; } public
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code sample"); package bankprj3; class Account { private double Balance; public Account(double initBalance){ Balance=initBalance; } public
sum
sum  s=(1+2)/(1x2)+(1+2+3)/(1x2x3+)+.......+(1+2+3+......n terms)/(1x2x3x..........n terms
sum
sum  s=135.............17 (mul of 1 to 17 odd numbers
sum
sum  how t0 get this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?  i have multiple(app..100) text... two columns the same as in the 100 files..and the data is to be writen from 3rd
how to print a new line after a certain number of prints
how to print a new line after a certain number of prints  How do I make this program print the inputs the user gives 5 per line? So in other words I want the program to print 5 input numbers per line. this is my code so far
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ask user how many numbers to be inputted and determine the sum and highest number using an array in java  ask user how many numbers to be inputted and determine the sum and highest number using an array in java
from number to word
from number to word  i want to know weather there is any method that can be use in changing value from number to word. Example if i write ten thousand, it will automatically be written as 10000.   Java convert number
Solving task 1 by 1 from bundle of task data
Solving task 1 by 1 from bundle of task data  Hello and namaste guys, i really need help here.i use ResultSet to query data from database. as we know... set.what should i do so that the solve code solve data 1 by 1?do i need to use
error:Parameter index out of range (1 > number of parameters, which is 0).
error:Parameter index out of range (1 > number of parameters, which is 0...=request.getParameter("des"); String From=request.getParameter("From"); String... into experience(candidateid,org,desg,from,to,expdetail) select * from candidate where
1 Access Infotech Number one Company - Servlet Interview Questions
1 Access Infotech Number one Company  1 Access Infotech is Number one Company who know the feelings of cutomers feel free ask any query Access Infotech Pvt. Ltd. Unit 5B, 4th Floor, Topaz Building, Punjagutta
How to pretty print XML from Java?
How to pretty print XML from Java?  How to pretty print XML from Java
Java Sum of Digits
Java Sum of Digits In this Java Tutorial section, you will learn how to find the sum of multidigit number. For this purpose, we have allowed the user to enter... + " is " + sum); } } Output Enter multi digit number: 123456789 sum
how to print from right to left in java????
how to print from right to left in java????   can anyone pls tell how to print from right to left in java
passing from 1 jsp to another - JSP-Servlet
passing from 1 jsp to another  Hi Sir, What are the ways and means of passing from 1 jsp page to another page.what are the different types of methods?  Hi Friend, You can use tag,sedRedirect() method
How to Create Multiplication Table from 1 to 10?
How to Create Multiplication Table from 1 to 10?  Hi, I want... table 1 to 10. Please suggest online example related to creating multiplication table. Thanks   Hi, Did you want to create multiplication table 1
multiply of 100 digits numbers
multiply of 100 digits numbers  multiplying 100 digits numbers to eachother
sum of the series
sum of the series  Program to sum the series 1+1/1!+1/2!+1/3!+....n
sum in JTable
sum in JTable  how to calculate sum from JTable's one field like total
 

 

 

DMCA.com