what is the diffrence between ++x , x++ pleaaaaase ???
Answers were Sorted based on User's Feedback
Answer / dallasnorth40
++ before the variable increments the variable before the
value is taken/used.
++ after the variable takes/uses the value, then increments.
Given:
int x = 5;
int y = 0;
y = x++;
This will leave y = 5 and x = 6.
y = ++x;
This will leave y = 6 and x = 6.
| Is This Answer Correct ? | 27 Yes | 3 No |
Answer / abhishek
This means if you declare the value for x=2 and used in
loop, while printing the value of ++x it will print 3 and if
used x++ then it will print 2 and then increment the value
for x and then next rotation it will print 3.
eg.1)
.....
..
..
++x OR x++;
printf("value of " ++x OR x++);
...
..
..
| Is This Answer Correct ? | 23 Yes | 3 No |
++x is pre-increment
say for example
the value of a=1
int a,r;
r= ++a;
now the value of "a" is incremented to 2 n then assigned to r...
x++ is post increment
say for exmaple
the value of a is 3
int a,r;
r=a++;
the value of a(initially 3) will be assigned to r..... n
then the value of "a" gets incremented to 4.
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / divya prabhu
++x means preincrement x, and then assign .
i.e
first increment x ==> x+1 and then assign the incremented
value back to x ==> x=x+1
x++ means postincrement x, and then assign .
i.e
first assign value of x to x==> x and then increment value of
x, x ==> x+1
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / chandrakant rohi
++x
it means pre-increament ,before execute the x first it increment
Ex int x=10;
printf("%d",++x);
ans=11
and
x++ means post_increament,first excute the statment and then increment ;
Ex
int x=10;
printf("%d",x++);
ans =10;
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / prabu
++x mean pre increament
eample:
for(i=1;i<=1;i++)
{
printf("i value is=",i);
}
the output: i=1
x++ mean post increament
example:
for(i=1;i<=1;++1)
{
printf("i value is =",i);
}
the output: i=2
| Is This Answer Correct ? | 2 Yes | 2 No |
Write an algorithm that receives a string and reverses it.
Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.
0 Answers ABC, Guidance Software,
what is the difference between int &r and int& r
can we declare an object of a class in another class?(assume both class as public classes)
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
5 Answers ADP, Amazon, HCL, IBM, Infosys, Satyam, TCS, Vimukti Technologies,
Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37
Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.
Find the maximum product of three numbers in an array? Eg. 9,5,1,2,3 Max product= 9*5*3= 135 The array can hav negative numbers also..
write a program to convert temperature from fa height into celcius and vise versa,use modular programming
0 Answers Jomo Kenyatta University,
Question 1: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date. *This Should Be Done IN C++
what is the diffrence between ++x , x++ pleaaaaase ???
What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }
3 Answers CTS, IBM, Infosys, Qatar University,