Faqs Cs201 Introduction To Programming
Faqs Cs201 Introduction To Programming
Faqs Cs201 Introduction To Programming
FAQs
Question: What’s the difference between void main and int main?
m
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
co
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
y.
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
ud
harder to type "return 0;" than "return;", and it will save you time in the future.
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
w.
{ ("begin bracket")
and }
("end bracket")
to group the set of statements that form the body of a loop.
while ( Expression ) {
statement-1;
statement-2;
...
statement-n;
m
This is known as strong type checking, something which C lacks.
co
Question: What is an Array?
Answer: An array is a data structure that allows storage of a sequence of values. The values are
y.
stored in a contiguous block of memory. Arrays allow fast random access to particular
elements. If the number of elements is indefinite or if insertions are required then we
can’t use an array. Example:
ud
int idnumbers[100];
This declares an array of 100 integers named idnumbers.
Question:
st
What is the relation between pointers and Arrays?
Answer: There is an important relation between pointers and arrays. By defining: int a[10]; “a”
ne
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:
bi
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,
w.
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
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:
m
· Essential C++ by Stanley Lippman
co
· The C++ Programming Language by Bjarne Stroustrup
y.
· The C Programming Language by Brian Kernighan and Dennis Ritchie
ud
Question: What is Dev-C++? st
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.
ne
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
bi
available for free and anyone can use it and take the benefit of it.
m
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.
w.
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
ww
the user
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
m
co
y.
ud
st
ne
bi
m
co
w.
ww