Chapter
No-01(Overview of C)
========================================================================
.
**State where the following statement are true or false.
a)
Every line a C program should end with semicolon.
(false)
b) In C lowercase letters are significant. (true)
c)
Every C program ends with an END word. (false)
d) main ( ) is where the program begins its execute.
(true)
e)
A line in a program may have more than one
statement. (true)
f) A printf statement can generate only one line of
output. (true)
g) The closing brace of the main ( ) in a program is
the logical end of the program. (true)
h)
Every C program must have at least one
user-define function. (true)
i)
Only one function may be named main ( ). (true)
** Fill in the blanks with appropriate words in each
of the following statements.
a) Every program
statement in a C program must end with a semicolon. b) The printf
function is used to display the output on the screen.
c) The math.h header file contains
mathematical function.
**
Why and when do we use the #define derivative?
Ans: In the C Programming
Language, the #define directive allows the definition of macros within your
source code. These macro definitions allow constant values to be declared for
use throughout your code. Macro definitions are not variables and cannot be changed
by your program code like variables.
** Why and when do we use the #include derivative?
Ans: Let's look
at an example of how to use #include directives in your C program. In the
following example, we are using the #include directive to include the stdio.h
header file which is required to use the printf standard C library function in
your application.
**What does void main(void) mean
Ans: This line gives the name of the function
that we have written and information about what goes into and out of the
function. In this case, the
name of the function is main. C not only allows
you to use library functions, it allows you to write your own functions.
Normally, your first programming assignment will be to write the main function.
Every C program has a primary function that must be a assigned the name main.
The name main is mandatory and cannot be altered by you, the programmer. In
other words, even if your program had the purpose of printing your address to
the screen you could not name the primary function printmyaddress and have the line
be void printmyaddress(void). The function must be called main.
**Distinguish between main() and void main(void)?
Ans: main() - it means that main function will
return an integer type of argument and empty parenthesis means it will not
receive any command line argument.
void main(void) - it means main will not return
any argument and also it will not receive any command line argument. If you
don't specify any return type before function name then by default it is
considered to be of type "int" and empty parenthesis or void in
parenthesis means same thing, function is not going to receive anything
**Distinguish between int
main() and void main(). Ans:
Difference between int main() and void main():
See like any other function,
main is also a function but with a special characteristic that the program
execution always start from main. So the function main needs arguments and a
return type. These int and void are its return type. Void means it will not
return any value, which is also ok.
But if want to know whether
the program has terminated successfully or not, we need a return value which
can be zero or a non zero value. Hence the function becomes int main () and is
recommended over void main ().
**Why do we need to use comments in programs?
Ans: In computer programming, a comment is a
programmer-readable explanation or annotation in the source code of a computer
program. They are added with the purpose of making the source code easier for
humans to understand, and are generally ignored by compilers and interpreters.
Ans: 'Look of your program' is very important if
you are working in an IT industry, as your program is going to be referred by
many people. When they read your program they should get clear idea what that
program is written for and they should not even need to read all the program.
How can you do that?
What is more important is 'Coding Standard' that
you use rather that look.
When you write a
program you must use some coding conventions, i.e. standard variable name
format, function name format and other coding formalities.
**Where are blank spaces permitted in a c program?
Ans: Blank
spaces are permitted in the print function in c programming language.
**Describe the basic structure of C program.
Ans:
Basic structure of C programming:
To write a C program, we first create functions
and then put them together. A C program may contain one or more sections. They
are illustrated below.
1. Documentation section The
documentation section consists of a set of comment lines giving the name of the
program, the author and other details, which the programmer would like to use
later.
2. Link section: The link section provides
instructions to the compile to link functions from the system library such as
using the #include directive.
3. Definition section: The definition section
defines all symbolic constants such using the #define directive.
4.
Global
declaration section: There are some variables that are used in more than one
function. Such variables are called global variables and are declared in the
global declaration section that is outside of all the functions. This section
also declares all the user-defined functions.
5. main () function section: Every C program must
have one main function section. This section contains two parts; declaration
part and executable part
6. Declaration part: The
declaration part declares all the variables used in the executable part.
7. Executable part: There is
at least one statement in the executable part. These two parts must appear
between the opening and closing braces. The program execution begins at the
opening brace and ends at the closing brace. The closing brace of the main function
is the logical end of the program. All statements in the declaration and
executable part end with a semicolon.
8. Subprogram section: If
the program is a multi-function program then the subprogram section contains
all the user-defined functions that are called in the main () function.
User-defined functions are generally placed immediately after the main ()
function, although they may appear in any order.
All section, except the main () function section
may be absent when they are not required.
- You Can download this as pdf by clicking below download icon-
Go ahead by honesty--->Rm
No comments:
Post a Comment