what is the value of b
if a=5;
b=++a + ++a

Answer Posted / anup dixit

13 is the correct answers. I'm attaching here a small java
program which proves this:

The program is:

------------------------------------------------------------

public class TestAddition
{
public static void main(String[] args)
{
int a=5;

System.out.println("1..Before a was : "+a);

int b = ++a + ++a;

System.out.println("Final a was : "+a+ ", int b =
++a + ++a is: "+b);

a=5;

System.out.println("2..Before a was : "+a);
int c= ++a+(++a);

System.out.println("Final a was : "+a+", int c=
++a+(++a) is: "+c);

}
}

------------------------------------------------------------

The output is:

------------------------------------------------------------

1..Before a was : 5
Final a was : 7, int b = ++a + ++a is: 13
2..Before a was : 5
Final a was : 7, int c= ++a+(++a) is: 13

Is This Answer Correct ?    15 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a stream?

639


Explain what is the difference between null and nul?

646


Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer

3831


What is a static function in c?

612


Write a code to generate a series where the next element is the sum of last k terms.

725






What does. int *x[](); means ?

627


a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor

629


What is adt in c programming?

602


Differentiate fundamental data types and derived data types in C.

604


What are integer variable, floating-point variable and character variable?

597


What is structure in c definition?

565


Is null always equal to 0(zero)?

574


How is a pointer variable declared?

585


Why do we need arrays in c?

572


In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]

1951