×
Study for the day when you don't have to worry about price tags.
--Your friends at LectureNotes
Close

Programming in C

by Kishore Kumar Reddy
Type: NoteInstitute: S.G.GOVT DEGREE COLLEGE Specialization: Computer Science EngineeringOffline Downloads: 72Views: 2142Uploaded: 5 months agoAdd to Favourite

Share it with your friends

Suggested Materials

Leave your Comments

Contributors

Kishore Kumar Reddy
Kishore Kumar Reddy
Programming in C C LANGUAGE Name :C Designation : Leading computer language Father‘s name & Address : Mr. Dennis Ritchie, AT&T, Bell Laboratories, Murray Hills, New Jersey, USA. Year of birth : 1972 Historical Background Year Name of the language ALGORITHMIC LANGUAGE-60 1960 Short form Developed by ALGOL-60 International Group Too theoretical and not much useful in practice. The Cambridge Very large and hard to University, USA. learn as well as to use LANGUAGE Mr. Martin Too specific and less Richards The powerful Cambridge University, USA. Mr.Ken Thompson, Too specific AT&T, Bell Labs, Murray Hills, New Jersey, USA. Mr.Dennis Ritchie, Consists of the AT&T, Bell Labs, combined good Murray Hills, New features of both BCPL Jersey, USA. and B, and many additional features created by Mr. Dennis Ritchie. 1963 COMBINED CPL PROGRAMMING 1967 1970 BASIC BCPL COMBINED PROGRAMMING LANGUAGE B B 1972 C Status  C Features : Middle level language C has fast programming ability like high level languages, but not as much as that of high level languages.  C has program execution ability like that of low level languages, but not as much as that of low level languages, viz. Assembly language and machine language.  Since C stands between both of them, to call it a middle level language. ___________________________________________________________________________ Page 1 Prepared by J.Kishore Kumar Reddy & Dr A.Ravi Prasad
Programming in C BASIC ELIMENTS In C , the basic elements include the set of characters, keywords, identifiers, data types, constants, variables, declarations, expressions, statements and symbolic constants. THE BASIC ELEMENTS OF „C‟ Name of the Element 1 Character set Keywords Contents/Characteristics Name of the Element Contents / Characteristics 2 3 4 Words, expressions and statements can be formed by the combination of alphabets, digits and symbols  Alphabets    Digits Special symbols Blank spaces In C, 32 Keywords are available. They are also called ‗Reserved Words‘ because each word is reserved for a predefined purpose.  Upper Case A,B,C…Z(26), Lower Case a,b…z(26)  0,1,2,3,4,5,6,7,8,9  # , * ,-, +, \, /, ;, :, ?, ! etc.  Non-printing characters. Auto, double, if, static,  Break else, int, struct, Case, enum long, switch, Char, extern typedef, union, Const, float register, void, Continue return, unsigned, while, Default for, short, do, Goto, signed  sizeof, volatile Each key word has a standard and pre-defined meaning and a pre-defined purpose as well. The meaning or purpose of keywords cannot be changed by a user. CONSTANTS C constants can be divided into two major categories as: 1. Primary constants and 2. Secondary constants ___________________________________________________________________________ Page 2 Prepared by J.Kishore Kumar Reddy & Dr A.Ravi Prasad
Programming in C Primary constants can be divided into three types: a) Integer constants b) Real constants c) Character constants Secondary constants are divided into several types namely arrays, strings, structures etc. Classification of Constants CONSTANTS PRIMARY CONSTANTS Integer Real Constants Constant SECONDARY CONSTANTS Character Constant Arrays Strings Structures PRIMARY CONSTANTS Primary constants are mainly of three types. They are: a) Integer Constants  An integer constant is formed with an integer number.  Integer constants do not have decimal point.  The number may be positive or negative.  It includes zero also.  If no sign precedes the constant, it is taken as a positive constant. E.g:- 32768, -25, +25, 1000 , +32767 are valid integer constants. b) Real Constants  This is also called Floating point constants.  Real Constants must have decimal point.  Integer constants can‘t express a value in fraction or decimal form. Values of temperature, height, weight, prices etc., are normally in decimal form. In such cases, we should use real numbers.  These numbers have a decimal point and they are either positive or negative. ___________________________________________________________________________ Page 3 Prepared by J.Kishore Kumar Reddy & Dr A.Ravi Prasad
Programming in C  If no sign precedes the number it is always positive.  No blank spaces, commas or special symbols (except (.) decimal point) are not allowed in real constants. E.g:- 0.25, -1.25, -0.251, +25.1  In no value is present either on the left-hand side or the right-hand side of the real number, the normal practice is to write zero/s. E.g:- 0.25, 5.0, 00.2, 0.20, -0.2, +7.0 (all these are valid real numbers) C) Character Constants  A character constant is a single character  It is either a single alphabet (lower or upper case), a single digit, a special symbol or a blank space enclosed within single quotes (‗) both pointing towards the left.  The length of the character constant must be one E.g: ‗X‘ ‗a‘ ‗5‘ ‗#‘ ‗ ‗ (The last one is the blank space charater) d) String constants  A string constant is sequence of characters enclosed within double quotes.  The characters include alphabets (lower case or upper case), digits, special characters and blank spaces.  This can also be defined as an array of (sequence of) character constants, whose last characters is \0 (null) character, which is automatically placed at the end of the string by the C compiler. E.g:- ―VERY GOOD‖, ― 2000 YEAR‖, ―$50K‖, ―A‖, ― ‖ (Null String) E)Blank slash Character Constants :  These are collectively called ‗ESCAPE SEQUENCES‘ because they are mainly used to create an escape from the present position.  The common features of all the escape sequences are they are formed with 2 characters. The first one is always the back slash (\) character and the second one is a lower case letter. E.g:- \n, \b, \t, \r, etc. ___________________________________________________________________________ Page 4 Prepared by J.Kishore Kumar Reddy & Dr A.Ravi Prasad

Lecture Notes