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 |
output for printf("printf");
i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.
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,
Complexity T(n) What is the time complexity T(n) of the following portions of code? For simplicity, you may assume that n is a power of 2. That is, n = 2k for some positive integer k. a) ? for (i = 1; i <= n; i++) { j = n; cout << i << ? ? j << ? ? << endl; } b) ? for (i = 0; i <= n; i += 2) { j = n; cout << i << ? ? j << ? ? << endl; } c) ? for (i = n; i >= 1; i = i/2) { j = n; cout << i << ? ? j << ? ? << endl; } d) for (i = 1; i <= n; i++) { j = n; while (j >= 0) { cout << i << ? ? j << ? ? << endl; j = j - 2; } }
Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and calculate its complexity T(n).
1 Answers Infosys, Qatar University,
#include<stdio.h> #include<conio.h> void main() { char str[10]; int,a,x,sw=0; clrscr(); printf("Enter a string:"); gets(str); for(x=0;x<=a;a++); for(x=0;x<=a;x++) { if(str[x]==str[a-1-x]) { sw=1; } else sw=0; } if(sw==10 printf("The entered string is palindrome:"); else printf("The entered string is not a palindrome:); } getch(); } wht would be the explanation with this written code???
what is the diffrence between ++x , x++ pleaaaaase ???
write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.
write a program that can locate elements in array.
Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)
Write code for the multiplication of COMPLEX numbers?
i don't know about working of nested for loop can any one help me