Solved

Definitions of basic C terms

Posted on 2003-11-10
3
383 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

746 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

12 Experts available now in Live!

Get 1:1 Help Now