write single statement in C language
first reduce the value A by 1, then find the sum of A and B, then increment the value of B by 1. and assign to the C.??
thats question
I solve like this tell me this is correct.
C= --A + B++
write single statement in C language
first reduce the value A by 1, then find the sum of A and B, then increment the value of B by 1. and assign to the C.??
thats question
I solve like this tell me this is correct.
C= --A + B++
a–;
b++;
c=a+b;
#include <stdio.h>
int main(void) {
int a, b, c;
a=10, b=10;
c=--a+(++b);
printf("%d", c);
return 0;
}
c=–a+(++b);
if you do c=--a+b++;
value of b
is incremented after assigment operation not before so you have to do it ++b
, if you do it c=--a+++b
; it gives error, so just use parentheses like c=--a+(++b);
but dear top of the question ask me write a single statement??
ok got it thank you dear