Questions tagged [c]

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.

Filter by
Sorted by
Tagged with
-2
votes
0answers
17 views

C programming -QUESTIONS [closed]

: In your own steps, write an ALGORITHM to greet a student as per grade [O, A+, A, B+, B, C, D, E (reappear), F (fail)] entered by the student. Think of the greeting messages as per grades, yourself. ...
0
votes
0answers
11 views

whats the use of Elf64_Symbol struct?

below is two pictures in regards to Executable and Linkable Format(ELF): My questions is: we know that Relocatable Object Files in ELF format are binary code(0s and 1s), so is Elf64_Symbol struct ...
0
votes
2answers
53 views

Are C standard library functions considered part of C programming language

Do we consider functions like printf part of C language even if it's not a keyword in it.
1
vote
0answers
23 views
2
votes
4answers
75 views

How do compilers assure stability?

Suppose you need a c compiler. It would be preferable to write that compiler in a c-like language, given the complexity of a compiler of that degree. At best, the c compiler would be written in c, but ...
9
votes
7answers
4k views

Checking equality of integers: O(1) in C but O(log n) in Python 3?

Consider these equivalent functions in C and Python 3. Most devs would immediately claim both are $O(1)$. def is_equal(a: int, b: int) -> bool: return a == b <...
1
vote
1answer
198 views

What are the known ambiguities in C language grammar?

I have found this reference for the C syntax Backus-Naur Form (BNF). I was wondering if there are any other ambiguities in this grammar other than the infamous "dangling else"? Also how we ...
0
votes
2answers
51 views

Understanding memory leaks in C/C++ [closed]

I was looking at an example here: https://blog.parasoft.com/finding-memory-leaks-in-c ...
0
votes
0answers
25 views

How do I compare these ranges of numbers efficiently?

I'm looking for an efficient way of testing eights. What happens is I need to check if a value is eights and discard it. The numbers I need to check for are: ...
0
votes
2answers
27 views

Error handling in a size_t hashfunction

For school I have a big assignment on hashtables etc. One of the functions is a size_t function where we calculate the hash value. (Keep in mind the structure of every function is given so we are not ...
0
votes
0answers
29 views

Protecting a specific sized message with some limitations

So I make a research on my own. I have a device it allows a 64bit message. I wanted to secure it but I 64bits arent just enough to hash it and encrypt it. Is there really any good Hash function out ...
0
votes
1answer
30 views

When does kernel accessing virtual memory cause problems

I'm working with the CPU Pintos and have a question that is: In which situations can the kernel accessing the data in virtual memory via a pointer lead to problems? And how do you avoid them? I know ...
1
vote
2answers
90 views

Is call stack compile time or runtime detail?

I'm sorry if the question is quite naive, but I don't understand if a call stack is a language implementation detail or it depends on OS? What I'm trying to understand is what decides how to store ...
1
vote
1answer
45 views

does a non-terminated string count as a token in c?

so, I am preparing for an exam which includes lexical analysis from compiler design. I was wondering what is the number of tokens in the following code- ...
0
votes
0answers
56 views

What are the errors in the following program?

Consider the following C code: ...
0
votes
0answers
16 views

Manage nested recursions in the design of a concatenative language interpreter

I'm in the designing of an interpreter for a stack based concatenative language, and I'm currently stuck with a problem about recursion of some of my concatenative program to calculate factorial: <...
3
votes
2answers
89 views

What does the following algorithm approximate? (Assume m>1,ϵ>0)

x = m; y = 1; While (x-y > ϵ) { x = (x+y)/2; y = m/x; } print(x); The answer is m½, its the Babylonian algorithm for square roots. I understand the ...
1
vote
1answer
72 views

Global variables and frame stack [closed]

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 ...
1
vote
1answer
87 views

How does dynamic memory-allocation exactly work?

I have wondered about ordinary code. Assume we are running this code on any modern System like Unix/Linux/Mac/Windows. This code is C, but it should work with every language which is close to the ...
1
vote
0answers
39 views

Design considerations of datatypes in early programming languages like C

Although type theory originated (e.g. already discussed by Russell in 1910s) much earlier than programming languages, I have this feeling that languages such as C considered type-checking from a very ...
1
vote
2answers
475 views

How does casting really work for primitive data types? [closed]

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: ...
1
vote
1answer
83 views

Sizeof function definition in a system

Why sizeof(int) and sizeof(int *) takes different value in a system? I mean generally size of integer is 4 B, but size of integer pointer is 8 B. But why they cannot take same value, although their ...
1
vote
1answer
239 views

Complete the following table by specifying the scope of each declaration

I'm having a hard time understanding this question. Can each declaration have more than one scope or can a declaration have more than one scope? If it's the later it would be: Declaration ...
-2
votes
1answer
52 views

Doubt in definition of Float

Can anyone tell the meaning of the bold portion? Float: It is used to store decimal numbers (numbers with floating point value) with single precision.
0
votes
0answers
84 views

Is C actually turing complete follow up [duplicate]

I am picking up from this thread for which I have no privileges to comment on: Is C actually Turing-complete? I was wondering if there's any progress on this and what the conclusion actually was. ...
0
votes
2answers
62 views

Where can I code in C? [closed]

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 ...
2
votes
1answer
269 views

In a kernel, what are “global constructors”?

I am a beginner developing kernels (though I have developed several Hello World programs in C and C++). I frequently see reference being made to global constructors (e.g., osdev https://wiki.osdev.org/...
1
vote
0answers
66 views

Why the name static and dynamic in static and dynamic scoping

I am wondering, from where static and dynamic scoping got their names. After understanding the concept of static and dynamic scoping in C, what I assume is that whenever we failed to find out the ...
0
votes
1answer
159 views

Convert for loop into math sigma notation

Have some code (written in C), need the equivalent notation for mathematics. Is it possible using if-statements and sigma notation for this, and if so, how? ...
1
vote
2answers
54 views

Are Kernel Codes (which are written in C) compiled during boot time?

I have a confusion regarding how the Kernel is loaded during the boot time. The intuition I have is like following: During installation of an OS, the compiled Code of the Kernel (depending on the ...
0
votes
3answers
979 views

What is standardization in computer science?

I was reading about the differences standards and specifications for C. I understood that programming languages are usually stadardized and I learnt that there are different approches to ...
0
votes
1answer
73 views

How should I “read” a dereference operator?

For example, when I look at some code like int x = 1; int * y = &x; I can read it like ...
2
votes
1answer
383 views

Doubt regarding address calculation in two-dimensional arrays

I am reading about the address calculation formulas for one and two-dimensional arrays. I have two related doubts concerning it. In one of the problems, we are asked to calculate the ...
0
votes
3answers
2k views

Traverse Matrix in Reverse Diagonal strips

I thought this problem had a trivial solution, couple of for loops and some fancy counters, but apparently it is rather more complicated. So my question is, how would you write (in C) a function ...
1
vote
0answers
895 views

trying to understand the diagonal check of 8 queen problem

I was solving the 8 queen problem and tried to look through the internet for comparison solutions to see how my solutions compared to others. I found one very small bruteforce solution that confused ...
0
votes
2answers
1k views

Since physical memory is the RAM where is logical memory stored on the computer?

Since logical memory maps to the RAM (physical memory) it has be stored somewhere right and it will obviously take large bunch of memory of itself. Where is it stored?
3
votes
3answers
367 views

How to enhance my skills as a programmer [closed]

I want to learn Cryptography and so I am interested to master C-programming. I know the basic concepts of C-programming like how to use an array,pointers etc. I want to develop myself so that I can ...
4
votes
0answers
187 views

Dennis Ritchie citation for “the C declarator syntax is an experiment that failed”?

I've often heard that the C declarator syntax described as "an experiment that failed." I've seen claims that this sentiment is also shared by its creator Dennis Ritchie. Does anybody have an actual ...
4
votes
1answer
158 views

Sorting Algorithm with constraints

I am looking for a sorting algorithm to help me in my work. My objective is the following: after receiving an input of this kind: 5 4 1 2 2 3 3 4 4 5 The first ...
1
vote
1answer
90 views

Formal specification; Logical formula

* Initial Question * I'm trying to write a logical formula consists of three Boolean variable C1, C2, C3. My program takes graph as input and checks properties about them. C1 represents presence of ...
0
votes
1answer
690 views

Column Major Order

I have a doubt understanding How a 3-Dimensional array is stored in column Major Order. An array in Row Major order is stored like [plane][row][column] So, for finding address of any element we cross ...
28
votes
2answers
4k views

Why is C's void type not analogous to the empty/bottom type?

Wikipedia as well as other sources that I have found list C's void type as a unit type as opposed to an empty type. I find this confusing as it seems to me that <...
46
votes
12answers
13k views

Is C actually Turing-complete?

I was trying to explain to someone that C is Turing-complete, and realized that I don't actually know if it is, indeed, technically Turing-complete. (C as in the abstract semantics, not as in an ...
2
votes
1answer
728 views

Hash multiple integers directly using FNV-1a

An alternative version of FNV-1a hash spread on the internet, which operates directly on integers instead of bytes. The offset basis and prime are the same used in the original version, which operates ...
2
votes
1answer
85 views
-1
votes
1answer
994 views

What is the difference between the friend class and inheritance consept in C++? [closed]

In C++ ,friend class allows us to inherit the proprieties of one class to another class(es) which is also possible using inheritance. And also in inheritance we can set different levels of privileges ...
2
votes
1answer
165 views

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) [closed]

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 ...
1
vote
2answers
173 views

use of C library in operating systems [closed]

I wonder, how is that operating systems make use of libraries as stdio.h if they themselves are the services? I am right? Is the operating system that interacts with the hardware to operations of I/O? ...
0
votes
0answers
679 views

Find the index of minimum number that is greater than key given of a sorted array, does these two functions return same result?

Give an array of integer has been sorted (non-decreasing order), we need find the index of minimum number number that is greater than key given, I wrote two functions, they're identical except the ...
1
vote
0answers
33 views

How is a complied program updatable? [closed]

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 ...