27.04.2021 Views

Yashavant Kanetkar - Let Us C-BPB Publications (2016)

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

12 Let Us C

statement, after the statement or within the statement as shown

below.

/* formula */ si = p * n * r / 100 ;

si = p * n * r / 100 ; /* formula */

si = p * n * r / /* formula */ 100 ;

(d) The normal language rules do not apply to text written within /* ..

*/. Thus we can type this text in small case, capital or a

combination. This is because the comments are solely given for the

understanding of the programmer or the fellow programmers and

are completely ignored by the compiler.

(e) Comments cannot be nested. This means one comment cannot be

written inside another comment. For example,

/* Cal of SI /* Author: gekay date: 25/06/2016 */ */

is invalid.

(f)

A comment can be split over more than one line, as in,

/* This comment has

three lines

in it */

Such a comment is often called a multi-line comment.

(g) ANSI C permits comments to be written in the following way:

// Calculation of simple interest

// Formula

What is main( )?

main( ) forms a crucial part of any C program. Let us understand its

purpose as well as its intricacies.

(a) main( ) is a function. A function is nothing but a container for a set

of statements. In a C program there can be multiple functions. To

begin with, we would concentrate only on those programs which

have only one function. The name of this function has to be main( ),

it cannot be anything else. All statements that belong to main( ) are

enclosed within a pair of braces { } as shown below.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!