Programming questions are off-topic here. Do not ask questions about how to write code in C. However, conceptual questions about computer science are more appropriate. See our help center for the scope of this site.
Questions tagged [c]
104 questions
10
votes
10 answers
In C, why limit || and && to evaluate to booleans?
In some languages, e.g. Ruby, an expression like:
val = call_fn() || DEFAULT_VAL;
will set val to the results of call_fn() if it is truthy (non-zero, non-NULL, etc), or to DEFAULT_VAL otherwise. This can be really useful.
In C, the result of the…

fearless_fool
- 435
- 5
- 12
2
votes
1 answer
What is this question asking for?-->Test this code, find an error in the program and "construct an instance to demonstrate the error" (in C)
I am learning the basics of the language C, and so far we have covered up to loops. This question is related to my assignment. The problem is I do not understand what the question is asking.
I know the error in the code, but I don't understand what…

Robo
- 21
- 1
1
vote
0 answers
How is a complied program updatable?
We all know in the case of web sites, to make update just means opening the code, editing it and saving it. And to view the changes we just have to refresh the browser.
But what about in the case of compiled programs like a game or other apps or…

Nino Stephen
- 11
- 1
1
vote
1 answer
C: iterate over a unicode (utf-8/utf-16) string, conditionally modify individual characters, and store it as new string
C's char array can hold an ASCII string, such that a user can query individual characters by indexing the char array, modify them or do what ever they want to, its pretty straight forward. I have browsed through many questions+answers on…

codepoet
- 111
- 2
1
vote
1 answer
Global variables and frame stack
The below program will read a positive integer from keyboard and print the binary equivalent. This program is using only one variable.
If global variables are not stored in frame stack, how this is working.
#include
int n;
void binary(n)
{
…

Krishnajith MV
- 11
- 1
1
vote
2 answers
How does casting really work for primitive data types?
I have written the following C code which purpose it is to flip an unsigned number in binary representation and give back an unsigned number:
long flippingBits(long n) {
return (unsigned)(~n);
}
int main(){
long a =…

TVSuchty
- 287
- 1
- 9
0
votes
2 answers
finding wrong elements in a descending sorted array using binary search
i have this question where im given a an array that contains the distance of a traveler from a certain destination at the i-th time of the day. ideally the array should be in descending order but the array could contain mistakes where the traveler…
0
votes
1 answer
How to visualize 1 pixel?
The CS50 course by Edx that I am pursuing has this statement in their Week 4 practice set:
A 24-bit BMP file, then, is essentially just a sequence of bits, (almost) every 24 of which happen to represent some pixel’s color.
If I understand…
0
votes
0 answers
How to merge both, mutable and immutable worlds?
In the ideal world, systems are designed using immutable data structures. However, when you dive deeper into lower levels of abstractions, you realize that at some point a library written in C is being used to performs some tricks that merge the…

Yulio Granja
- 1
- 1
0
votes
1 answer
Difference between bits and bytes?
What are bits and bytes? How do they differ? What role do these notions play in the computer science world? Why do talk about 8 bits = 1 byte = 256 states or different patterns? What's the rationale behind it? Why not 4 bits = byte? What is so…

Vinay Sharma
- 23
- 6
0
votes
0 answers
What is bit (or binary digit)?
So, if I were to represent 23 in binary, what are bits here? Are 0 and 1 called bits? What they mean when they say I have five bits of information?

Vinay Sharma
- 23
- 6
0
votes
1 answer
Pointers and Dereference Operator
*a = *b
In C, the above expression is always interpreted as the assignment of the value at the address contained in b to the value at an address in a.
But, according to the precedence of operators and associativity rule, * has higher priority than…

Aman Rathore
- 23
- 5
0
votes
2 answers
Where can I code in C?
I have an upcoming CS course in uni that uses C and I want to get ahead a little bit this Christmas break but I'm having a hard time figuring out where I can actually code using C. My school uses this compiler called Seashell but it's not available…

ming
- 111
-1
votes
1 answer
Simple error in C
I cannot determine why the Celsius values in this code are producing rubbish values. (Look at second statement in the first for-loop).
CODE:
/* The program will output two columns with the temperature in degrees Fahrenhiet
and equivalent…

Ryan J. Shrott
- 123
- 5