[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Definitions of basic C terms

Posted on 2003-11-10
3
Medium Priority
?
391 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 46

Accepted Solution

by:
Kent Olsen earned 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

872 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