Tuesday, July 28, 2009

Questions for C Language Excepts Only?

Plz Can anybody answer below questions





-%26gt;What is the most efficient way to count the number of bits which are set in a value?


-%26gt;How can I convert integers to binary or hexadecimal?


-%26gt;How can I call a function, given its name as a string?


-%26gt;How do I access command-line arguments?


-%26gt;How can I return multiple values from a function?


-%26gt;How can I invoke another program from within a C program?


-%26gt;How can I access memory located at a certain address?


-%26gt;How can I allocate arrays or structures bigger than 64K?


-%26gt;How can I find out how much memory is available?


-%26gt;How can I read a directory in a C program?


-%26gt;How can I increase the allowable number of simultaneously open files?


-%26gt;What's wrong with the call "fopen("c:\newdir\file.dat", "r")"?


1. Explain working of printf.


2. Explain "passing by value", "passing by pointer" and "passing by reference"


3. Have you heard of "mutable" keyword?


4. Talk sometiming about profiling?


5. What is Memory Alignment?


6. Why

Questions for C Language Excepts Only?
-%26gt;What is the most efficient way to count the number of bits which are set in a value?





Lookup table





-%26gt;How can I convert integers to binary or hexadecimal?





What do you mean? As a string? Just use the printf modifiers.





-%26gt;How can I call a function, given its name as a string?





Use a map of pointers to functions





-%26gt;How do I access command-line arguments?





main( int argc, char * args[] )


argc has the arguments count, args has argc arguments - the command line argsuments





-%26gt;How can I return multiple values from a function?





Via pointers in the arguments





-%26gt;How can I invoke another program from within a C program?





You should not. But system() gets the job done.





-%26gt;How can I access memory located at a certain address?





Use a pointer, set pointer to that certain address





-%26gt;How can I allocate arrays or structures bigger than 64K?





WTF? Are you in 16bit real mode under dos or what? Read the system docs.





-%26gt;How can I find out how much memory is available?





Use OS calls ( see your OS documentation )





-%26gt;How can I read a directory in a C program?





What do you mean by read? See OS docs.





-%26gt;How can I increase the allowable number of simultaneously open files?





See OS docs





-%26gt;What's wrong with the call "fopen("c:\newdir\file.dat", "r")"?





Not portable?


Handle not saved?


Folder not available?





Even if there is a problem, it is specific to your code. So I cannot help.





1. Explain working of printf.





See http://www.cplusplus.com/reference/clibr...





2. Explain "passing by value", "passing by pointer" and "passing by reference"





C has no passing by reference. In c++, see http://www.cplusplus.com/doc/tutorial/fu... - similar in C except for reference part





3. Have you heard of "mutable" keyword?





Yes. But it is C++, not C. http://www.cppreference.com/keywords/mut...





4. Talk sometiming about profiling?





It evaluates how long each of the functions run in a program. Used for optimizations/debugging.





5. What is Memory Alignment?





http://en.wikipedia.org/wiki/Memory_mana...





6. Why





Why What?


No comments:

Post a Comment