Solved

Definitions of basic C terms

Posted on 2003-11-10
3
384 Views
Last Modified: 2012-05-05
Hi, i have some questions in regards to C programming.

1) I am wondering, what is the difference between absolute & relative boolean statements?
2)How is storage space allocated for dynamic variables?
3) What is an indexed function?

Can some one provide answers with examples for the above questions?

Thanks in advance.  :-)
0
Comment
Question by:FOXBAT
3 Comments
 
LVL 45

Accepted Solution

by:
Kdo earned 50 total points
ID: 9714929

1)   In general, conditional boolean expressions get translated by the compiler into branches of control, i.e. "if" statements, whereas absolute boolean expressions may be translated in a similar way to arithmetic expressions.  Relative boolean is a term that I'm unfamiliar with.

2)  All dynamic variables will be placed on the stack or the heap, depending on how they are created.  The general rule is, if C creates the variable it goes on the stack and if the user code creates the variable it goes on the heap.

3)  An indexed function is simplay an array that contains the addresses of functions instead of data values.  It turns code like this:

if (a==0)
  Function0 ();
else if (a == 1)
  Function1 ();
else if (a ==2)
  Function2 ();

into this:

void *FunctionTable[3] = {Function0, Function1, Function2};

FunctionTable[a]();  /*  Execute Function0, Function1, or Function2 depending on the value of a  */



Kent

0
 
LVL 22

Expert Comment

by:grg99
ID: 9715206

1) I am wondering, what is the difference between absolute & relative boolean statements?

Hmm, never heard of "absolute" or "relative" as applied to booleans, and never heard of a "boolean statement" either.
Boolean *expressions*, boolean *functions*  boolean *operators*, boolean *variables*, but I can't fathom what a "boolean statement" might be.  Perhaps eitehr you or the question writer is a bit confused?


2)How is storage space allocated for dynamic variables?


variables local to a function or  {} block are allocated on the stack.  The stack is a very simple and economical way to allocate variables.  Only drawback is they can only be deallocated in a Last In, First Out fashion.    If you need a dynamic variable to persist longer than that, you have to allocate it on the "heap" with new or malloc or similar function.    These variables stick around until you explicitly free() them.  Heap storage is a bit more expensive and problematic to use, as the heap can get fragmented and heap allcoaton htakes a bit more time than stack allocation.



3) What is an indexed function?

No idea.   It could be an array that holds function pointers, or a function that returns an array index, or a function that you apply an index to.

Since this quiz seems to have a distressing number of "special" terms, you might have to start attending the lectures to pick up all these special terms that your teacher seems to be making up.  

0
 

Author Comment

by:FOXBAT
ID: 9719474
Thankx, just as i thought = D
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now