With esionhow learn C programming language! Problem 1 + + i and i + +

Category: C/C++ -> C Author: wooncher Date: 2014-12-14 10:18:30
 
wooncher
2014-12-14 10:18:30
# Include <stdio.h>

main ()

{
int a = 3, b, c , i = 10;
b = a + +;
c = + + b;

; printf ("a =% d, b =% d, c =% d \ n", a, b, c); / * Question 1: Why a = 4, b = 4, c = 4 it * / should be: a = 3, b = 4, c = 5 ah.

printf ("i, i + +, + + i =% d,% d,% d \ n", i, i + +, + + i) ;/ * Question 2: Why i, i + +, + + i = 12,11,11 it * / should be: 10,11,12 ah

printf ("+ + i =% d \ n", + + i); / * Question 3: Why is + + i = 13 it * /
printf ("- i =% d \ n", - i);
printf (" i + + =% d \ n ", i + +);
printf (" i - =% d \ n ", i -);
printf ("-i + + =% d \ n",-i + +);
printf ("-i - =% d \ n",-i -);
getchar ();
getch ();
}

output is:

a = 4, b = 4, c = 4

i, i + +, + + i = 12,11,11

+ + i = 13

- i = 12

i + + = 12

i - = 13

-i + + = -12

-i - = -13

I was a novice Please good people answer. Thank
kongfu_2010
2014-12-14 10:24:23

#include <stdio.h> 

main() 


    int a=3,b,c,i=10; 
    b=a++;//a b  ++  ; b=3 a=4 
    c=++b; //b ++   b=4  c  C=4

    printf("a = %d, b = %d ,c = %d\n",a,b,c);

    printf("i,i++,++i=%d,%d,%d\n",i,i++,++i);//  printf     ++i i++ i
                                                  //++i   i=11 i++ ++   VC6 11 11 11 

    printf("++i=%d\n",++i); // ++i  ++   i ++  ( printf )  ++  13 
    printf("--i=%d\n",--i); 
    printf("i++=%d\n",i++); 
    printf("i--=%d\n",i--); 
    printf("-i++=%d\n",-i++); 
    printf("-i--=%d\n",-i--); 
    getchar(); 
        getch(); 

FHSMGG
2014-12-14 10:35:37
Thank you for your help. Extremely grateful
xinaixinai
2014-12-14 10:50:08

positive solution.
WANGLONGPUAN
2014-12-14 10:58:15

puzzling to say, according to the first floor guy said, VC6 before an ellipsis in the above (that is: printf ("i, i + +, + + i =% d,% d,% d \ n ", i, i + +, + + i) ;/ / this place should have a relationship with your compiler printf op is from right to left to see it look + + i i + + i
; ; / / + + i operate first time i = 11 i + + is + + so the first output after I get VC6 result was 111,111) of is output should 12,11,11 ......
absss
2014-12-14 11:10:54
int a = 3, b, c, i = 10;
; b = a + +;
c = + + b;

printf (" ; a =% d, b =% d, c =% d \ n ", a, b, c);

a + + is the first implementation of a past that is again a semicolon has been equal to 3 after the end of that four of the phrase.
Since then there has been a three sentence so put three assigned b a.
+ + b (plus sign in front) is executed before the first b plus a sentence (when b is equal to 4 a) and then execute the statement. So put four assigned c, so c = 4
caijiepersonal
2014-12-14 11:20:34


it should be 121,111