Faq 201
Faq 201
Answer: getch ( ) is used when you want to get a character from the user via keyboard. getch ( )
does not display the character pressed by the user from the keyboard. It returns ASCII Code of the
character pressed by the user.
getche ( ) works same like getch ( ) except it displays the character pressed by the user. It returns ASCII
Code of the character pressed by the user.
getchar ( ) works like getch ( ) and getche ( ) except it will continue inputting the character until Enter is
pressed. It returns the ASCII Code of first character entered by the user
Question: What is a rand () function?
Answer: rand ( ) is a random number generator function. The function rand ( ) returns a value
between 0 and 32767
Question: What is the difference between exit ( ) and exit (1)
Answer: exit ( ) terminates the calling process. if 0 is passed to the exit (0) its a Normal
termination and if 1 is passed ,exit (1) , then its an Abnormal termination. Error in process
Question: What is Dev-C++?
Answer: Dev-C++ is a C++ IDE in which we can write C++ code, compile and run it. It has both
Compiler and Editor in it.
Question: Why are we using Dev-C++?
Answer: We are using Dev-C++ because it is a Freeware. Freeware is such a software which is
available for free and anyone can use it and take the benefit of it.
1|Page
Question: What is the relation between pointers and Arrays?
Answer: There is an important relation between pointers and arrays. By defining: int a[10]; “a” by
itself is of type (int *) - a pointer to int, and has the value &a[0] (the address of a[0]). So we can do the
following: int *pa = a; since pointers are just numbers (i.e. numeric memory addresses) we can do
arithmetic operation on them:
int *pb = pa+1; /* now pb points to a[1] */
*pb = 1; /* now a[1] = 1 */
*(pb + 2) = 3; /* now a[3] = 3 */
Question: When I compile a file in Dev-C++, I get a message saying "could not find file name“
Answer: Check in Compiler options if the directories settings are correct. With a default setup, you
should have :
C:\DEV-C++\Bin
c:\DEV-C++\Include
c:\DEV-C++\Include
c:\DEV-C++\Lib
For further help in Dev C++, you must consult Help on Dev C++, given in the help menu
Question: I am having problems using Borland specific functions such as clrscr()
Answer: If you are using Dev-C++ 4 then include conio.c else include conio.h in your program
file. For further help in Dev C++, you must consult Help on Dev C++, given in the help menu.
Question: Are there any other books for reference than C++ how to program?
Answer: Yes there are many some of them are listed below:
· Sams Teach Yourself C++ in 21 Days by Jesse Liberty
· C++ Primer by Lippman and Lajoie
· Essential C++ by Stanley Lippman
· The C++ Programming Language by Bjarne Stroustrup
· The C Programming Language by Brian Kernighan and Dennis Ritchie
· The C Answer Book by Gimpel and Tondo
Question: What are pointers?
Answer: A pointer is a variable that represents/stores location of a data item, such as a variable or
array element
Question: What’s the difference between void main and int main?
2|Page
Answer: Void main (): You can't return a value from void main. i.e., you can't return 0; at the end
of main (). You can use "return;" but no value is passed back to any program that called it. This may not
seem like much of a problem to you at this point; but it *will* become important as you create more
complex programs.
int main (): Returns a integer value at the end of execution. The value returned can be a standard 0 or any
other int to represent and number of errors/choices/results/etc... int main () is a standard.
Go for int main (), if for no other reason than that it’s a good coding habit. It’s no harder to type "return
0;" than "return;", and it will save you time in the future.
Question: What is #include?
Answer: #include is pre-processor macro. Preprocessor includes the whole file you specify with it
so basically it's same as you would write the whole header file in your program. However program's size
doesn't increase by including files. It's linker's duty to link only symbols that are needed and leave others
behind. The program file will start with #include statements that tell the compiler to read the "headers"
describing the libraries that the program uses.
Question: What does main( ) do?
Answer: Main ( ) provides the entry point into the program. Compilers only recognize statements
that are with in the braces of main ( ), all other functions are called from main ( ). For more help visit
http://www.cs.uow.edu.au/people/nabg/ABC/C6.pdf
3|Page