Skip to main content

Posts

Showing posts with the label IntroC

Type Declaration Instruction:

This instruction is used to declare the type of variables being used in the program. A variable is a location in RAM (main memory) for temporary storage of intermediate data. Any variable used in the program must be declared before using it in any statement. The type declaration statement is written at the beginning of main() function. Ex:        int bas;             float   rs, grosssal; char   name, code; These are several subtle variations of the type declaration instruction. i) While declaring the type of variable we can also initialize it as shown below: int i=10, j=25; float a=1.5, b= 1.99+2.4 * 1.45 ; ii)   The order in which we define the variables is sometimes important sometimes not.       For exa:             int i=10,j=20; is same as    ...

The layout of C Programs

The general form of a C program is as follows: pre-processor directives global declarations main() {    local variables to function main ;    statements associated with function main ; } f1() {    local variables to function 1 ;    statements associated with function 1 ; } f2() {    local variables to function f2 ;    statements associated with function 2 ; } . . . etc Note the use of the bracket set () and {}. () are used in conjunction with function names whereas {} are used as to delimit the C statements that are associated with that function. Also note the semicolon - yes it is there, but you might have missed it! a semicolon (;) is used to terminate C statements. C is a free format language and long statements can be continued, without truncation, onto the next line. The semicolon informs the C compiler that the end of the statement has been reached. Free format also means that you can a...