Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
What does this line of code mean?
if((c-a)!=0 && (d-b)!=0) goto trap;
What does the !=mean?
I inherited this, and I'm not sure what it means.
It means: if c is not equal to a, then if d and b are also not equal, goto (jump to) the line with the label "trap".
The !=, just means not equal. It is the complement of the == operator.
Not equal.
1 != 2
1 == 1
2 != 1
3 != 5
!= means not equal to.
ex: c-a is not equal to 0.
a != b means that a is not equal to b. It's the same as !(a == b).
Here's an english translation of the code...
if c minus a is not equal to 0 AND d minus b is not equal to 0 then goto trap
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Write a single statement to accomplish each of the following. Assume that variables c (which stores a character), x, y and z are of type int, variables d, e and f are of type double, variable ptr is of type char * and arrays s1[100] and s2[100] are of type char.
Determine whether the value of c is a letter. Use the conditional operator to print " is a " or " is not a " when the result is displayed.
printf("%s",((c >= 141 && c<= 172) || (c>= 101 && c<= 132)) ? "is a " : "is not a ");
The C programming has a feature of being case-sensitive. C and c have different ASCII values as characters AND they're different too as identifiers.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
Why output is z=0 in the program written below ?
why isn't it giving any error?
Please Explain
#include<stdio.h>
int main()
{
int x=3,y,z;
y=x=10;
z=x<10;
printf("x=%d, y=%d, z=%d",x,y,z);
return 0;
}
Output :
x=10, y=10, z=0
According to N1570 draft (c11):
6.5.9 Equality operators
The == (equal to) and != (not equal to) operators are analogous to the relational operators except for their lower precedence. Each of the operators yields 1 if the specified relation is true and 0 if it is false. The result has type int.
So in your case, condition is false, because 10 is not less that 10, so 0 is stored to the z.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
What's really happening behind?
int a=10,b=5,c=3;
b!=!a;
c=!!a;
Why the values of b and c are 5 and 1 respectively?
b is 5 because you've assigned it that value and never changed it, since
b!=!a;
...is just a condition that you don't do anything with, not any form of assignment.
c is 1 because a is 10 and !10 is 0, and !0 is 1, thus !!a is 1 (a is 10).
You already have got the answer to your question, but just to have a deeper look into why it happens that way, let me add my two cents here.
An expression like
b!=!a;
is same as
b != !a;
because of the maximal munch rule used in the translation phase. Basically, this says that the longest possible token should be selected from the input while creating a construct (obviously, valid/ meaningful).
Following this principle the ! and = are considered together to form the perfectly valid operator != and the expression is parsed like
b != !a;
over
b ! = !a; //or anything else.
That is why, there is no assignment, as you might have thought.
That said, ! is an unary operator, which does not change the value of the operand. So, taken together, your code is essentially same as
int a=10,b=5,c=3;
c=!!a; //double negation
so, a and b are unchanged, and c is 1 (because !!10 == !0 == 1 )
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have this code troubling me for a while.The expression at Line 7 is troubling me. Is it giving 0 or -1. If its 0 then answer is 2 else answer is 4.
/* How to find value of c in Line 7 expression */
#include<stdio.h>
int main()
{
int a,b,c=1;
a=b=c; // a,b,c have equal value
c=b+=a=-c; // what will be the output of this expression?
c=-c;
c=(++c)*2;
printf(ā%dā,c);
return 0;
}
In C the pre-increment (decrement) and the post-increment (decrement) operators requires an L-value expression as operand. Providing an R-value or a const qualified variable results in compilation error.
An lvalue is a value that can be assigned to.
/* what is value of c */
That's easy to answer: Your question does not make any sense.
Since your code won't compile, c won't have a "value".
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I am wondering how to make it so that if lets say the variable A isnt equal to 1 and 2 do
printf("Unknown letter type again\n");
thanks in advance if you know what to do and also is it possible if you type a letter to make you type a known letter
if (A !=1 || A!=2){
printf(foobar);
}
After you changed your question, the answer would be...
if (A !=1 && A!=2) {
printf(foobar);
}
if (!((A == 1) || (A == 2)))
{
printf("Unknown letter type again\n");
}
if A is not 1 or 2: print message
but if you are working with numbers in text/ASCII, you need to compare A == '1' instead of A == 1.