473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

postfix prefix of c++.... i am unable to solve the problem... please kindly help me t

i am not able to solve the following-

M= (++N)+(++P++)
N= ++P--
P= --M++
M= ++P
N= --M
P= ++N
Print M+N+P=?
Please kindly help me to solve it...
Jun 23 '13 #1
2 1366
weaknessforcats
9,208 Expert Mod 8TB
You are allowed to change the value of a variable only once in a statement. Otherwise, the behavior is indeterminate.

So this code:
Expand|Select|Wrap|Line Numbers
  1. M= (++N)+(++P++)
will give you different answers on different compilers.

Compilers are allowed to evaluate the variables in any order, left to right or right to left before making any decisions using those variables. As a result, a variable that changes within a statement has an indeterminate value.
Jun 23 '13 #2
Banfa
9,065 Expert Mod 8TB
Additionally these 2 lines will not even compile

N= ++P--
P= --M++

because ++ and -- (prefix or postfix) have to operate on an lvalue (basically a value you can assign to) but in these lines the prefix operators act on the output of the postfix operators and these are not lvalues, you can't assign to them as they have no memory address.
Jun 24 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: baby pink | last post by:
kindly solve the problem in article one .. its quite urgent thanx for reading goog luck pink
2
by: shan | last post by:
Hi to everybody, I am begginer in C programming language. My simple doubt is the difference between postfix & prefix unary operator plus. (i.e) i++ and ++i . plz give me an example program...
2
by: Naveen Mukkelli | last post by:
Hi, I'm sending multicast messages UDP socket and C#. But the receiving clients are not receiving all the messages. Receiving clients are missing out some messages. When I debug the server...
6
by: Federico | last post by:
Hi, this is what I can do: - Create new solutions using VS.Net ASP.Net - Save the solutions, build the solution, view in browser with the solution still open. But, once I close the solution, I...
0
by: Jitesh | last post by:
I am facing a problem in webservice, I want to know what will be the exact procedure to solve the problem............. What I want to do............ I have a table named order in SQL Server....
1
by: gkellymail | last post by:
I currently have a class with 29 data adapters and I will probably add a few more as time goes on. When I was testing earlier, i had 28 of them pointing to one connection and 1 pointing to a...
17
by: khajeddin | last post by:
the problem is: Create a class HugeInteger which use 40-element array of digits to store integers as larg as 40 digits each.Provide methods input, output, add, subtract how to add to arrays ?
5
by: rsingh | last post by:
HI guies can u help me to solve this problem. Write a program that prints a table of the binary equivalents of the decimal numbers in the range 1 through 256.
1
by: cooklooks | last post by:
http://www.videoriporter.hu/vr/fs?content=/vr/player/1320/date/count
3
by: vagandhi | last post by:
Hello friends, I am having problem while running below program. If anyone can help me.... // create class car #include<conio.h> #include<iostream.h> #include<stdio.h> // class declaration
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.