All Questions
606
questions
0
votes
0
answers
35
views
How to numerically solve the diffferential equation giving the ground states of a Bose-Einstein condensate?
I am trying to solve the differential equation giving the ground states of a Bose-Einstein Condensate in 2D. I need to solve it in C/C++.
I have an equation that is as follows : (vn+1-vn)/dTau = 1/2* ...
-2
votes
2
answers
134
views
Make easely a sub array from an array
Check this c/c++ code, but just pay atention to the use of "&" operator and the array operations into the function. Its ok to pass an array like that?, will be any invalid access problem ...
0
votes
2
answers
81
views
When is the dereferencing operator useful? [duplicate]
I am a newbie c-coder, so this probably has a very simple answer. I understand the function of pointers and the dereferencing operator, but I'm not sure when they're actually useful?
Basic example:
...
2
votes
0
answers
32
views
Operators precedence/pre-post operators [duplicate]
In running the below code, I got 25 which really puzzles me...any explanation?
I was expecting 20 (4 times 5 or 5 times 4)
#include <stdio.h>
int main()
{
int a=3; int res=++a*(a++ +1);
...
-1
votes
1
answer
102
views
Why is the && operator is acting as || in this c code and vice versa? [duplicate]
I was Writing a program that prints all possible different combinations of two digits and in good formatting:
Numbers must be separated by a comma and followed by a space except the last digit it ...
3
votes
4
answers
228
views
How to change 1 to zeros in the binary form in C
I can't figure out how to change any consecutive 1 to zeros in the binary form of x (consecutive 1 means a set of 1 that contains more than one 1).
Problem specifications:
Allowed operators: ! ~ & ...
-1
votes
1
answer
80
views
Confusion regarding precedence of C operators [duplicate]
I"m quite confused about the following block of code:
int a = 1, b = 2, c = 3;
printf("%d ", c - 3 && b++ > c);
printf("%d %d %d", a, b, c);
Initially, I thought ...
-1
votes
1
answer
58
views
How to divide int * type? [closed]
I'm trying to find from input to if is "Armstrong Number" or not. Here's my code. Probably I have another arrow but I can't divide (/) or multiplication (*) with int * variables. Why is ...
1
vote
1
answer
95
views
Unexpected result in C program with increment operator
This statement int b = (a) + a++; is supposed to assign the value 8 to variable b, where a is initially assigned the value 4. However, the output of the program is 9 instead of the expected 8.
I ...
1
vote
4
answers
763
views
How can I reliably perform an arithmetic shift right in C++?
The "arithmetic shift right" operation is similar to a normal (logical) shift right, except the most significant (i.e. shifted-in) bits are filled with the sign bit rather than 0. ...
1
vote
2
answers
94
views
Does working of increment and decrement operator change if used with logical operators [duplicate]
#include <stdio.h>
int main()
{
int a = -10, b = 3, c = 0, d;
d = a++ || ++b && c++;
printf("%d, %d, %d, %d, ", a, b, c, d);
a = -10, b = 3, c = 0;
d = c++ &&...
1
vote
1
answer
103
views
What is "<:" in C?
I'm troubleshooting some simple tutorial code for XMOS processors and I've come across an operator that I've never seen before in C. What does <: do? As it is used here, it appears to set a ...
0
votes
0
answers
28
views
how is 1st code working to get 21 while when same value is assigned to **b** the post increment operator doesn't work? [duplicate]
when running the below code the output is 21
#include<stdio.h>
int main()
{int a=10,b=10;
printf("%d",a+(a++));
}
whereas running below code gives output 20
int main()
{int a=10,b=...
2
votes
2
answers
107
views
What are all the details behind the operation of += and similar operators in C?
Yes, I know, this seems like a no-brainer to google. I know full well that x += y does the same thing as x = x + y. That's not my question here.
My question is what on earth this line of code is doing ...
0
votes
2
answers
104
views
Usage of '+=' in c
I don't understand why, on this code, 'b+=' return 6 instead of 5. The operation on right-end of operator '+=', should be 0.
i/2 = 4
a-4= 0
So Operator '+=' should just add: 0.
#include<stdio.h&...