[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Definitions of basic C terms

Posted on 2003-11-10
3
Medium Priority
?
390 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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 how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

649 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