Notes of FY B. Tech Computer, Computer Programming In C BASIC COMPONENTS OF PROGRAMMING - Study Material
Page 1 :
BASIC COMPONENTS OF PROGRAMMING:The basic component of C includes token, keywords, variables, constants, data, types etc. Let us see some details of these basic components of C programming, language., Tokens and Keywords:1 Token:In C language tokens are the smallest element. A token may be a single character or, a sequence of characters to form a single item for c program. Tokens can be numeric, constants, character constants, keywords, names (lable or identifiers), punctuation or, operators used for different kinds of operations including arithmetic and numeric, operations., 2 Keywords:In any programming language, some words are reserved for some special use., These words are not allowed to be used by programmers for their own purpose., These words are called keywords and sometimes called reserved words. Also C, language like any other programming language has defined some keywords. Every, keyword has a fixed meaning to the compiler and cannot change the meaning. For, example int is used for representing integers., C keywords are given below:, , auto, , else, , long, , switch, , break, , enum, , register, , typedef, , case, , Extern, , return, , union, , char, , float, , short, , unsigned, , const, , for, , signed, , void, , continue, , goto, , sizeof, , volatile, , default, , if, , static, , while, , do, , int, , struct, , _Packed, , double
Page 2 :
Variables:Once you have data to store, you need to associate with a specific memory location., These memory locations are given some names and these names are called variable, names. The value stored in these locations can change or vary throughout the, program‟s lifetime. These data are referred to with variable names. Each Variable, has a specific type, which is known as a variable data type. This data type tells the, computer how much memory is taken by the variable to store the data., Name of a variable must start with letters and contain letters, digits, and, underscores. For example x, y, z, sum, number_of_points, mars12 are valid variable, names. A variable must be declared in a C program before being used. Variable, declaration tells the compiler about variable names and their type., Constants:A constant can be seen as a type of variable which does not change its value in a, program. There are many types of constants in c such as numeric constant,, character constant , string constant etc ., Character constants are typically just the character enclosed in single quotes; 'x', 'y',, 'z'. Some characters can't be represented in single quotes. For them a two character, sequence is used., For example:, New line „\n‟, Single quote – „\‟‟, Back slash – „\\‟, Numeric constants are a continuous sequence of digits (and may contain a period)., A numeric constant never contains a comma., Examples of numeric constants: 123, 55.45, 100