what is code for adding two integers in java?, Computer Engineering

import java.util.Scanner;
 
class AddNumbers
{
   public static void main(String args[])
   {
      int x, y, z;
      System.out.println("Enter two integers to calculate their sum ");
      Scanner in = new Scanner(System.in);
      x = in.nextInt();
      y = in.nextInt();
      z = x + y;
      System.out.println("Sum of entered integers = "+z);
   }
}

Posted Date: 3/11/2013 2:07:42 AM | Location : United States





you need to use the + operator for adding nos in java

ex,

int a=9;

int b=1;

int s=a+b;

System.out.println(s);

the output will be 10

Posted by | Posted Date: 3/11/2013 2:08:04 AM


Related Discussions:- what is code for adding two integers in java?, Assignment Help, Ask Question on what is code for adding two integers in java?, Get Answer, Expert's Help, what is code for adding two integers in java? Discussions

Write discussion on what is code for adding two integers in java?
Your posts are moderated
Related Questions
To avoid race condition, the maximum number of processes that may be simultaneously inside the critical section is The maximum number of processes is one to ignore race conditi

Difference between Visual check and Parity check Visual check This is checking for errors by comparing entered data with original document (NOTE: this is not the same as

What do you mean by best fit?  Best fit allocates the smallest hole that is big enough. The whole list has to be searched, unless it is sorted by size. This method makes the sm

Draw the logic diagram of 16-bit ROM Array and explain its principle of operation. Ans: 16-bit ROM Array: A ROM that is read-only memory is an array of selectively closed

Logic Programs: A subset of first order logic is "Logic programs". However logic program having a set of Horn clauses that are implication conjectures when there is a conjunct

Q. Define looping in assembly language? LOOPING  ; Program: Assume a constant inflation factor that is added to a series of prices ; stored in the memory. The program

#what is decoders? explain with diagram

Q. Characteristics of input- output channels? The I/O channel represents an extension of DMA concept. An I/O channel has ability to execute I/O instructions that gives complete

Backward Chaining: In generally given that we are only interested in constructing the path whether we can set our initial state to be the theorem statement and search backward

Dynamic address translation :  If, when executing an instruction, a CPU fetches an instruction located at a specific virtual address, or fetches data from a particular virtual