Saturday 28 November 2015

TUTORIAL 2

USING TAGS

Include the following in the page

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.         WELCOME TO MY PAGE
  5. </body>
  6. </html>

<!DOCTYPE html>
  • specifies the type of webpage is html
  • it instructs the web browser which version of html is being used, html indicates HTML5
  • if document type declaration is not specified, browser may behave in a peculiar way
<html> the opening tag, denotes the beginning of the html document

</htmlthe closing tag, denotes the end of html document
  • whatever is written between will be considered as html document
<bodydenotes the beginig of the body of the html page

</bodydenotes the end of the body
  • So whatever you have typed now within the <body> and </body>, is the body 
  • WELCOME TO MY PAGE is the body here, and displayed in the browser window

  • </html </body> - closes the respective elements
  • All the tag do not have the closing tags. there are certain tags which do not have the closing tags
  • Tags which do hold any contents will close themselves. So they do not need a separate closing tag
eg<br> - denotes the line break

it doesnt wrap any content
this might also be written like <br/> 
it is a self closing tag. that mean, closing by itself.
generally used in xhtml coding
xhtml is another version of html based on another markup lanuage xml

  • Any tag which has content must be closed
  • Syntax : opening tag -> content -> closing tag
  • This makes the code easier to understand


TUTORIAL 1

WHAT IS HTML?

HTML - Hyper Text Markup Language
It is the standard markup language used to create web pages.
A markup language is a set of markup tags
HTML documents are described by HTML tags
Each HTML tag describes different document content
It is used by most websites to create visually engaging webpages, user interfaces for web applications, and user interfaces for many mobile applications
HTML markup consists of several key components, including those called tags (and their attributes), character-based data types, character references and entity references. 
We are here to learn HTML. 

              WHAT WE NEED TO START WITH HTML?

              Notepad is a common text editor on Windows-based computers (usually found under the Programs > Accessories menu) 
              Mac OSX computers come bundled with TextEdit 
              But any program that lets you fiddle with text will do. 

              LETS BEGIN !

              Type this in to your text editor: 
              My First HTML Page Welcome here 
              Now create a folder called “html” wherever you like to save files on your computer and save the file as “myfirstpage.html”. 
              It is important that the extension “.html” is specified
              Some text editors, such as Notepad, will automatically save it as “.txt” otherwise. 
              You also need to ensure that your file is being saved as plain text. 
              Make sure you check the “Plain text” format option before creating a new file. 
              Open a web browser and type in the location of the file, you just saved (e.g : “C:\html\myfirstpage.html”), in the address bar and hit return. 
              Alternatively, go to the File menu of the browser, select Open, and browse for the file. 
              Here we have created a very simple webpage of our own. Its that easy....

              You may be tempted to use a dedicated software program such as Adobe Dreamweaver. 

              You should be very careful when using these programs, especially if you are a beginner

              Software programs such as these will never give you the same control over a web page as coding by hand. 

              If you do decide to use specialized code-editing software, we recommend one in which you are still coding by hand. 

              Saturday 14 November 2015

              CONSTANTS

              Constants in C refer to the fixed values that do not change during the execution of a program
              There are basically 2 types of constants in C :
              1. Primary Constants
              2. Secondary Constants

              In this lesson, we will learn only about the primary constants: Numeric and Character Constants


              NUMERIC CONSTANTS


              There are two types of Numeric Constants 
              1. Integer Constants
              2. Real Constants

              INTEGER CONSTANTS

              An integer constant refers to a sequence of digits.There are 3 types of integers
              1. Decimal : Consists of a set of digits 0 to 9
              2. Octal : Consists of any combination of digits from 0 to 7 with a leading 0
              3. Hexadecimal :
              They may include alphabets A/a to F/f
              These alphabets represent the numbers 10 to 15 respectively
              Consists of the digits preceded by 0x or 0X
              Other rules for construction Integer Constants :
              1. It must not have a decimal point
              2. It could be either positive or negative
              3. If no sign precedes, it is assumed to be positive
              4. Embedded spaces/ blanks, commas and non-numeric characters are not permitted
              5. The allowable range for integer constants is -32768 to 32767 for 16 bit machines and -2 147 483 648 to 2 147 483 647 in 32 bit machines
              6. It is also possible to store large integer constants on these machines by appending qualifiers such as U/u, L/l and UL/ul to the constants

              REAL CONSTANTS

              A real constant is often called a Floating Point Constant.
              It could be written in two forms :
              1. Fractional Form
              2. Exponential Form
              Rules for constructing Real Constants for Fractional Form
              1. It must have at-least one digit (0-9)
              2. It must have a decimal point
              3. It could be either positive or negative, by default it is positive
              4. Embedded spaces, commas are not allowed with in a real constant
              Rules for constructing Real Constants for Exponential Form
              1. This form is usually used if he value of the constant is either too small or too large
              2. Here the real constant is represented in 2 parts
              3. Mantissa - the part before 'e'
              4. Exponent - the part following 'e'
              The general syntax : 
              mantissa e exponent
              1. Mantissa part and the exponential part should be separated by letter 'e'
              2. Mantissa part could be either positive or negative, by default it is positive
              3. Exponent must have at-least one digit which must be a positive or negative integer, by default it is positive
              4. Blank is not allowed
              5. Range of real constants expressed in Exponential Form is -3.4e38 to 3.4e38

              CHARACTER CONSTANTS


              There are 2 kinds of Character constants :
              1. Single Character Constants :
                • contains a single character enclosed within a pair of single quote marks 
                e.g: 
                '5'  'X'  ';'  ' '
                here '5' is character and different from number 5
              2. String Constants :
                • It is a sequence of characters enclosed in double quotes
                • The characters may be letters, numbers, special characters and blank spaces 
                e.g: 
                "Hello" "1987" "&...!" "X"
                here "X" is a string , different from character 'X'

              IDENTIFIERS

              In C, the names of variables, arrays, functions, labels and various user defined items are called identifiers.
              The variables, arrays, functions, etc. can be identified by giving them meaningful names.
              These names are called identifiers


              RULES FOR IDENTIFIERS


              1. The first character of an identifier must be an alphabet or an underscore
              2. Identifiers must consist of only alphabets, digits or underscore
              3. Special symbos are not allowed
              4. Keywords should not be used as the identifiers
              5. Identifier should be a single word, i.e., No blank space is allowed
              6. Identifiers can be both uppercase and lowercase. C is case sensitive, i.e., uppercase letters are different from lowercase letters
              e.g : ADD , AdD, add are different identifiers
               
              Valid Identifiers
              Invalid Identifiers
              ADD
              3add
              Numerics not allowed in the beginning
              Add
              add+123
              + is not allowed
              _add
              for
              it is a keyword
              Student_Name
              ABC XYZ
              Blank not allowed
              Name
              Student%123
              % Is not allowed
              A312B
              _Add*5Add
              * is not allowed
               
               

              Friday 13 November 2015

              KEYWORDS

              • The keywords are reserved for specific meanings in C language
              • C has nearly 32 keyword
              • Keywords, combined with the formal C syntax, forms the C programming language
              • The variables should not be named with any of the keywords as the meanings cannot be changed
              • All the keywords are lower case letters
              • Keywords are also called as reserved words
              • All the keywords have pre-defined meanings
              autodoubleintstruct
              breakelselongswitch
              caseenumregistertypedef
              charexternreturnunion
              constfloatshortunsigned
              continueforsignedvoid
              defaultgotosizeofvolatile
              doifstaticwhile
              • auto
                • auto is used to define a variable of storage class automatic. 
                • Variables declared within function bodies are automatic by default. 
                • They are recreated each time a function is executed. 
                • Since, automatic variables are local to a function, automatic variables are also called local variables.
              • break and continue
                • The break statement is used to jump out of the innermost enclosing loop (while, do, for or switch statements) explicitly and pass control to next statement immediately following the loop. 
                • In other hand, continue statement is used to skip certain statements inside the loop.
              • switch, case and default 
                • The switch statement tests the value of a expression and test with the different "case" values. 
                • We can use "default" value, if it doesn't matches any of "case" values. 
              • char
                • The char keyword is used for indicating the variable is of the type character. 
              • const 
                • const makes the value of a pointer or a variable unmodifiable. 
                • This value cannot be changed in program.
              • do and while 
                • while and do are used for looping in C. 
              • double and float
                • double and float are used for indicating floating type variables. 
                • Keywords float and double represents single precision and double precision floating point data respectively. 
              • if and else 
                • if and else are used in decision making in C.
              • enum : 
                • enum is used to define enumerated type data type. 
                • Enumerated data type creates a set of constant of type int. 
              • extern
                • Keyword extern is used for indicating the variable is external 
                • It is declared outside every function and can be accessed by any function. 
              • for 
                • Keyword for is used for looping in C. 
              • goto 
                • Keyword goto is used for unconditional jump to a labeled statement inside that function. 
              • int 
                •  int is used for indicating the variable is of type integer.
              • short, long, signed and unsigned : 
                • short, long, signed and unsigned are type modifiers that alters the meaning of base data type to yield new type.
              • return 
                • Keyword return terminates the execution of current function and returns the value to the calling function
              • sizeof 
                • sizeof is used to find the number of bytes of an object.
              • register 
                • Variable of storage class register are much faster than normal variables
              • static 
                • static is used for indicating the variable is of storage class static. 
                • The value of the static variables persists until the end of the program. 
              • struct 
                • struct is used in creating a structure which provide means to group different types of variable under one name for easier handling.
              • typedef 
                • Keyword typedef is used to explicitly associate a type with an identifier.
              • union
                • Union is used in creating a union which provide means to group different types of variable under one name for easier handling.
              • void 
                • void is used to indicate that a function takes no arguments or returns no value.
              • volatile 
                • volatile is used to create a volatile object. 
                • A volatile object can be modified in unspecified way by the hardware.

              C TOKENS

              • One or more characters grouped together to form basic elements of C are known as C Tokens
              • The C Tokens include identifiers, constants, variables, keywords, operators, strings and some special symbols




              C CHARACTER SET

              • The characters can be used to form words, numbers , statements and expressions
              • The characters in C are grouped into four categories :
                1. Letters / Alphabets : used for naming variables (identifiers) and keywords 
                2. Digits : used for forming numerical constants and naming variables
                3. Special Symbols : used as operators
                4. White Spaces  

               

              • One or more characters grouped together form basic elements of C known as tokens which are used for building declarations, statements and expressions etc.


              UNIT 3 : INTRODUCTION


              • C is a general purpose language 
              • Like any other high level languages, c has two distinct parts : Syntax and Semantics
              • Syntax of a C language specify character set, words, operators, statements, sentences and the rules
              • According to these syntax rules, valid C language program can be formulated
              • Semantics of C language assigns exact meaning of actions to be performed by these valid syntactic language
              • A program is a set of statements, which will be executed in a sequential form
              • These statement are formed using C character set, identifiers, variables, data types, constants, etc.
              • In this unit, we will learn about these basic elements which are used in the C language.


              Tuesday 10 November 2015

              PROGRAMMING STYLE


              • All statements should be written in lowercase letters
              • Uppercase letters are used only for symbolic constants
              • The programmer can write the statement anywhere between the two braces following the declaration part
              • The user can also write more than one statement in one line separating them with a semicolon
              • The opening and closing braces should be balanced, i.e., if opening braces are three, then closing braces should also be three
              • Use comments whenever necessary.
              • Comments increase the program readability and also help to understand the program logic

              EXECUTING A C-PROGRAM

              1. Creation of program
                • Program should be written in a C editor
                • After typing the program, save it with extension .c
              2. Compilation & linking of a program
                • Source program should be compiled using a C compiler.
                • Compiler checks for the syntax errors.
                • Once all the errors are corrected, compiler converts the source program into its equivalent machine language code called as the Object Program or Object Code
                • The object program is required for execution by the computer
                • Linking is also essential process that puts all other program files and functions, that are required by the program, together                                                 
                • e.g:
                  • If the program contains the built in function sqrt(), then the object code of this function should be linked to the main program from math.h library of the system
              3. Executing the program
                • After the compilation and linking, the executable code will be loaded in the computer's main memory and the program is executed


              Saturday 7 November 2015

              BASIC STRUCTURE OF C PROGRAM 3

              PROGRAM TO DEMONSTRATE ALL THE SECTIONS OF A C-PROGRAM


              OUTPUT

               

              BASIC STRUCTURE OF C PROGRAM 2

              MAIN FUNCTION SECTION


              • All the C program contains one or more functions but, there must always be one main() 
              • Execution of every C program begins from the function main() 
              • This section contains 2 parts :

              1. Declaration part - Declares all the variables used in the executable part.
              2. Executable part

              • These two parts must be within the opening and closing braces ({ and })
              • Program execution starts from the opening brace and ends at the closing brace
              • All the statements in the declaration part & executable part must end with a semicolon


              SUB - PROGRAM SECTION


              • This section contains the user defined functions.
              • These functions are invoked in the main function.
              • We can have any number of our own functions
              • These functions are generally placed after the main function, although they may appear in any order.
              • These functions are executed only when we invoke these functions



              BASIC STRUCTURE OF C PROGRAM 1

              • The C program usually contain one or more sections.
              • To write a C program we first create a function main to accomplish a specific task
              • A function is a subroutine that contains the statements, enclosing them within { and } to perform the required task.
              • Except the function main(), rest of the sections are optional.
              • Different sections of a C-Program are shown below :

              STRUCTURE OF C-PROGRAM





              DOCUMENTATION SECTION

              • Contains comments such as : program description, programmer's name, date on which it is written and other details required by the program
              • A comment in a C program is ignored by the compiler
              • '/*' is used to mark the start of a comment and it terminate with '*/'
              • There must be no gap between the asterisk (*) and slash (/)
              • Comments are used to enhance program readability and understandability by giving the description or other detail about the program
              • Comments may be placed anywhere in the program, but are not allowed in the middle of any keyword or identifier

              LINK SECTION


              • It helps to include the external file functions from the system library.
              • We must add an #include instruction in the program, which instructs the compiler to link the specified function in the library.
              • These library files are called as header files.
              • Header files can optionally be included in the program as per the requirement.
              • When we compile the C program,the header files are also compiled with the original program.
              • All the header files are included into the program by preprocessor directives.
              • Preprocessor directives are processed before a source program is handed over to the compiler.
              • these should be placed in a source program before the function main()
              • All the preprocessor directives should start with # and end without semicolon(;)

              e.g:

                • All the standard mathematical functions (e.g : sin, cos, exp, etc.) are defined and kept as a part of C math library <math.h>
                • Some standard input/ output functions are defined in standard input/output header file, <stdio.h>




              DEFINITION SECTION

              • This section defines all the symbolic constants.
              • Symbolic constants are defined a value using the #define instruction.
              • Whenever a symbolic name is encountered, the compiler substitutes the value associated with the name automatically
              • The values remain constant throughout the program, and are not allowed to re define the values in the program
              • #define is a pre-processor directive
              • #define lines should not end with a semicolon (;)
              • Generally symbolic constants are written in uppercase

              GLOBAL DECLARATION SECTION


              • This section contains variables that are used more than one one function. 
              • Any variable which is declared in this section is called as global variable and are available to all the functions