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

 
 


rhoxart faye rosario
print the sum of even number from 1 to 100
1 Answer(s)      2 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.

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 Pages:
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
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
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
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
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
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
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
Calculate sum and Average in java
= 0.0f; for (int i = 1; i <= num; i++) { sum = sum + i... the sum by the total number of numbers, we have determined the average of numbers...Calculate sum and Average in java  How to calculate sum and average
sum
sum  a program to find the sum of the alternative diagit of it ex- no=123456 sum=1+3+5=9
Logging Tutorial - Part 1
Logging Tutorial - Part 1 2000-12-14 The Java Specialists' Newsletter [Issue 003] - Logging part 1 Author: Dr. Heinz M. Kabutz If you are reading... in this newsletter useful. I drew some fire from respectable quarters that some
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
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
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
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
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
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
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
Java write even numbers to file
started a loop for numbers 1 to 50. If the number is totally divided by 2 leaving 0 remainder, then it should be an even number and stored in the file. We have used print() method to store the even numbers to the file. println
Sum of first n numbers
=input.nextInt(); long sum=0; for(int i=1;i<=n;i++){ sum+=i; } System.out.println("Sum of Numbers from 1 to "+n+" : "+sum...Sum of first n numbers  i want a simple java program which will show
How to print this in java?
and click the button that consists of binary number 0 and 1 from the text editor.    How to print this in java...How to print pattern in Java?  How to print a particular pattern
sum of fibonacci series
sum of fibonacci series  Write a Java program to print Fibonacci series upto n and find their sum also. 0+1+1+2+3+5+8+13+21ââ?¬Â¦Ã¢â?¬Â¦Ã¢â?¬Â¦Ã¢â?¬Â¦=sum   Hi, Please see the thread Fibonacci program. Thanks
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
GUESS NUMBER - Java Beginners
() { super("Guess Number"); randomNumber = new Random().nextInt(100) + 1... between 1 and 100 and lets you keep guessing until you get it right! You have two...); panelBottom.add(comment, BorderLayout.SOUTH); panel.add(new JLabel(" Guess a number from
Java programming 1 - Java Beginners
Java programming 1  hi there, Sir! Can u help me check where my program gone wrong? here are my coding =D, hope to get reply from u guys soon...,"Enter the number of marks", "Marks",JOptionPane.QUESTION
Sum - JSP-Servlet
to sum up from a particular row from the database, get all the rows affected... = con.createStatement(); ResultSet res = st.executeQuery("SELECT SUM(amount) FROM information"); while(res.next()){ amount = res.getInt(1
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
C calculate sum of first and last element of array
will learn how to calculate sum of first and last element from the array of five... and the last number and determine their sum. Here is the code... of first and last number is: %d", sum);      
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
SQL Aggregate Sum
SQL Aggregate Sum       The SQL Aggregate Sum Function is a part of Aggregate Function that is used to compute sum of the numeric field in a table. Understand with Example
Find Twin Primes Number using Java
primes and twin primes from the first 100 natural numbers. For this, we have used... by 1 and the number itself. Here we are going to find twin primes. Twin Primes... between 1 to 100: if ((i - LastPrime) == 2) { System.out.println("(" + (i - 2
Display Sum of Table Column Using In JSP
Bean..    Step 1: Create a web page(sum_count.jsp) to insert... Display Sum of Table Column Using In JSP... an application to Display the sum data of a Table column for a specific Date. We
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
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
Java number calculation using while loop
and secondNum inclusive. It also find the sum of all the even numbers between...+=num1; } num1++; } System.out.println("Sum Of Even Numbers: "+sum...: 5 7 9 11 13 15 17 19 Sum Of Even Numbers: 108 Numbers
Sum of seris
Sum of seris  Program to find the sum of the following series using a function declaration. sum=x-(xxx)/3!+(xxxxx)/5!-(xxxxxxx)/7!+.....(xx....x)/n!. Where n and x are entered from the keyboard
SQL Aggregate Sum
you the records from table 'Stu_Table'. The 'sum(marks)' in the select...'. select stu_id, stu_name, sum(marks) as 'total marks' from stu_table... SQL Aggregate Sum      
odd and even
{ System.out.println(); System.out.println("1 Display Even"); System.out.println("2...odd and even  how can i make a program of even and odd using case... Option: "); int choice=input.nextInt(); switch(choice){ case 1
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
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
Find sum of series
sum(int n) { if (n == 1) return 1.0; return sum(n - 1) + 1.0 / n...Find sum of series This section illustrates you how to find the sum of n terms... function that takes the parameter 'n' up to which the sum of the series
Find Sum of Diagonals of Matrix
elements. Here we are going to find the sum of Primary diagonal (From left top to right bottom)  and Secondary diagonal (From right top to  left bottom...Find Sum of Diagonals of Matrix You all know that a matrix is a rectangular
Get Random Number
the number and work as iterartor by using System.out.println. 1)Random.nextInt... Get Random Number       Random Number is the set of unordered arranged number. The class 
Magic number Java Program
1 and 255. I will guess the number you are thinking of. 1 3 5 7 9 11 13 15 17... The program prints out 8 sets of numbers. Notice the pattern: 1.starting at 1 print the number, skip the next one, print the next one, skip the next one, etc
JPA Sum Function
;SELECT SUM(p.price) FROM Product p"); This query calculate...) FROM Product p"); Number sumOfPrice=(Number) query.getSingleResult.... Hibernate: select SUM(product0_.price) as col_0_0_ from product product0

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.